What is the best way to track memory management when testing my iPhone app?

When developing my application, I realized that most of my application crashes were due to poor memory management.

I understand that I can print or record counting accounts through NSLog (@ "count count is:% d", [myInstance retainCount]);

But isn't there a better, less manual method? Perhaps a visual representation of your objects and instances?

answered. Greetings, Adam and Jason. :-)

+6
memory-management iphone cocoa-touch
source share
4 answers

Use the Leaks and Objects tools with Xcode.

Run > Start with Performance Tool > ... 
+6
source share

In addition to the other answers, I would highly recommend using clang to analyze the static memory of your code. He will not catch every memory management error, but it breaks down quite a lot. If your main problem seems to come from memory management errors, clang will go a long way toward finding these errors. Klang is free, http://clang.llvm.org/

+3
source share

As Adam suggests, Tools are a very useful tool for such things. It is fairly easy to use, but can be a little overwhelming at first. At startup, I suggest reading the User Guide for the tools . It is fairly easy to follow and useful until you have used the tools for a while. However, without even reading the manual, the tools are still much simpler and more intuitive than clogging your code with NSLog () calls and trying to parse the output yourself;)

+2
source share

I also found the NSZombie tag, useful for tracking cases of objects with release.

Basically, the link describes a β€œtrick”, so release objects are suppressed by replaceable NSZombie objects, which, if they are released, throw exceptions again.

You can then use Instruments to track where the object was selected.

0
source share

All Articles