objective c - Objects' retain counts never go below 1 despite deliberately overreleasing -
i checking on retain count of objects
nslog(@"r = %d", [aobject retaincount];
it seems lowest value can "r = 1", if deliberately add "release" calls
[aobject release];
the "r = 1" limit holds if try put "release" , "nslog" test codes in object's dealloc
method.
the cocoa run-time seems neglect releases "r = 1" before crashing "exc_bad_access" @ end of sample program (without gc).
my explanation (a guess) need r >= 1 object accessed. , cocoa run-time tries refrain letting object's retain count getting 0 prematurely.
can confirm or correct me if wrong?
when retain count of object reach 0 (i.e. retain count 1, , release has been called again), it's deallocated instead of bothering final decrement.
Comments
Post a Comment