How to check the number of delays during debugging

Does anyone know how I can check the number of times an object is held in debug mode? I tried to add the expression [objInstance retainCount] , but that did not work. I also tried the print object PO [objInstance retainCount] in the console, but again it did not work.

+8
debugging ios objective-c iphone retaincount
source share
2 answers

I assume you are talking about getting retainCount in GDB ?

You can use the retainCount method.

This is how I enter my code.

 (gdb) p (int)[product retainCount] $2 = 4 

Hope this is what you are looking for.

+6
source share

You can print this with

 NSLog(@"Retain count might be %d",[objInstance retainCount]); 

However, this number is not reliable due to things like autorelease . You should rather read memory management and make sure your retain and release calls match. You can also run assembly / assembly and analysis to get Xcode to help you find possible memory leaks, but again, these are just potential leaks. You definitely need to check each one to make sure.

+5
source share

All Articles