iphone - find out retain counts of variables
I don't have any problems with my iphone app. Theres no exc_bad_access or memory issues. However I know that I haven't properly allocated and released memory. I don't know why this isn't throwing any exceptions, but it isn't. Everything works.
I don't want to overload the iphone memory though, and am aware t开发者_StackOverflow社区hat just because I don't release an object doesn't mean its not still using memory, but now I am quite far through my app I can't be dealing with going back through and analyzing the whole program.
Is there any way of finding pointers and their retain count or find memory being used or anything?
Thank you.
You can use the tools that come with Xcode to detect both leaks and allocated objected. From Xcode, select Run > Start with Performance Tool > Leaks. Then choose the ObjectAlloc instrument. This will display all of the objects in memory.
This will only discover used memory for active objects, but not the retain count for individually allocated objects AFAIK.
If it's not throwing any exception it's because or you are keeping the retain count >= 0.
If you are not sure if the retain counts are equals 0, and you are concerned of leaking memory, you should run the Leaks instrument (Xcode->Run->Run with performance tool->Leaks).
You can also run the static analyzer to check possible leaks or other issues on your code (Xcode->Build->Build and Analyze).
Cheers,
vfn
精彩评论