Does anybody know how can I check the retain count of an object while in debug mode? I have tried to add an expression [objInstance retainCount]
but it did not work. I have also tried the print object PO [objInstance retainCount]
in the console but again it did not work.
I am guessing you are talking about getting the retainCount
in GDB
?
You can use the retainCount
method.
This is how I get in my Code.
(gdb) p (int)[product retainCount]
$2 = 4
Hope this is what you are looking for.
You can print this with
NSLog(@"Retain count might be %d",[objInstance retainCount]);
However, this number isn't reliable due to things like autorelease
. You should rather read up on memory management and make sure that your retain
and release
calls match up. You can also run Build/Build and Analyze to get Xcode to help you find possible memory leaks, but again, these are only potential leaks. You'll need to check each one yourself to be sure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With