Search code examples
iphoneiosmemory-managementinstrumentsnsmanagedobjectcontext

Instruments logging extra living objects


In the initialization of my app, I am reading some data out of a Core Data managed object context. For some reason, even though the executeFetchRequest line of code is called only once, I am seeing 5 living entries in the Instruments Allocations tool object listing. For example, if I drill down into the source code from within Instruments, I see this:

enter image description here

I set a breakpoint on this line, and verified that the app is stopping on this line only once. However, this is what I see as a result in Instruments:

enter image description here

If I look at the stack trace for each of these 5 objects, it is exactly the same, all pointing back to line 135 as shown in the first screen shot. (As you can see, I have tried a few different scenarios and all of them have the same result.)

So I have two questions here.

Question #1: Why do I see 5 living objects?

Question #2: Why are the objects living any way? From what I can tell, everything is being released correctly, and wrapped inside autorelease pools that should take care of these objects.

I am on Xcode 4.2 with the iOS SDK 5.0. Any ideas would be appreciated. Thanks.


Solution

  • The CFData instances are just chunks of data. Perhaps they represent records in the database, but not knowing the internals of CoreData, that's just speculation. They could represent cached data held by the managedObjectContext, but that too is mere speculation.

    If you're not seeing any leaks reported, I would not worry too much about it.

    Although if anyone has more insight into this, please chime in.