Does Apple's Xcode development environment provide any tools for memory leak detection?
I am especially interested in tools that apply to the iPhone SDK. Currently my favourite platform for hobby programming projects
Documentations/tutorials for said tools would be very helpful.
Yes. Apple calls them "Instruments" (there's more than just memory tools).
See Apple's
Introduction to Instruments User Guide
. In particular, seeLocating Memory Issues in Your App
. It provides examples of how to use the memory-oriented trace templates.ObjectAlloc and MallocDebug should both be of help to you. If you installed the entire SDK, they will be found in Developer->Applications->Performance Tools.
Their names give you a pretty good clue as to their functions, OA, tracks the objects create and MA is a general memory leak tool.
I haven't tried them with iPhone development yet, but I have to believe that they would work there as well.
Assuming you have registered for ADC iPhone developer site, here the link to follow:
Instruments User Guide
Made a sum up of the main memory leak tools:
iphone-essential-performance-tools-list
There is one specifically called
Leaks
and like a previous poster said, the easiest way to run it is straight from Xcode:It seems very good at detecting memory leaks, and was easy for a Non-C Head like me to figure out.
When using
rustyshelf's solution
make sure you test on the iPhone and not on the simulator. Memory usage is dramatically different.Select
Profile
from theProduct
menu in Xcode 6 to launch Apple's Instruments tool. (The application is located inside the Xcode application's package contents:/Applications/Xcode.app/Contents/Applications/
)A commercial alternative is OmniObjectMeter.(Discontinued by The Omni Group)