Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in ARC on iOS 5, can you see who caused a release?

In my iOS 5 project with ARC enabled, one of my objects gets released prematurely, so when I try to get to it later I get a null pointer. Before ARC, I would have simply overridden release like this:

-(oneway void)release {
    NSLog(@"-1");    //breakpoint goes here
    [super release];
}

then added a breakpoint on the NSLog and inspected the call stack to see who is causing a release.

How do I find out who "called" release under ARC? ("Called" might be the wrong word since the compiler inserts the release calls, so what I mean is "where is the line that the compiler inserted a release call?").

like image 1000
lmirosevic Avatar asked Feb 22 '23 12:02

lmirosevic


1 Answers

If you need to see where retains, releases and autoreleases occur for an object use instruments:

Run in instruments, in Allocations set "Record reference counts" on (you have to stop recording to set the option). Cause the problem code to run, stop recording, search for the ivar of interest, drill down and you will be able to see where all retains, releases and autoreleases occurred.

enter image description here

like image 120
zaph Avatar answered Mar 04 '23 19:03

zaph