I know this question is subjective b开发者_开发知识库ut I am brand new to Objective-C and the MacOS. Although I am trying to be diligent in my memory management I am sure my code is leaky. Can someone suggest a good tool to detect these leaks?
Thanks!!
There are leaks and then there are leaks.
Leaks is strictly defined as an allocation in memory for which there are no remaining references to said allocation and, thus, no way your app could use it again. As Bogatyr said, The Leaks instrument does a great job of tracking these down.
However, you might find that your app is still growing over time, a sure sign of a an additional problem. Regardless of whether or not it is truly a leak, such potentially unbounded growth in allocations is obvious very bad.
For that, use Heapshot analysis. I wrote a guide to doing exactly that people seem to dig. Maybe it'll help you, too.
Xcode has built-in tools, these are what developers typically use for debugging performance and memory issues. You can access them via the Run -> Run With Performance Tool -> Instruments -> Leaks. Also very useful in the NSZombies tool (here's one tutorial on using it: http://www.markj.net/iphone-memory-debug-nszombie/
In XCode you have an option, Build & Analyze (Shift-Cmd-A), that will check memory issues for you. This will find some of the memory management problems, but not all.
Note: Before running it, you may want to clean your target (Shift-Cmd-K) to make sure all project files are compiled.
After that you can use Instruments, with Leaks or Zombies as mentioned in the other answers.
精彩评论