NSIncrementalStore newObjectIDForEntity: Memory Leak
| Originator: | will.helling | ||
| Number: | rdar://13520827 | Date Originated: | 3/27/2013 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 6.1 |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
NSManagedObjectIDs created using -[NSIncrementalStore newObjectIDForEntity:referenceObject:] are never released under ARC. This is causing them to leak later on.
Steps to Reproduce:
I reproduced the problem simply by running this method somewhere in my NSIncrementalStore subclass and having an NSManagedObjectID category logging deallocs.
- (void)deadObjectIDs:(NSRelationshipDescription *)relationship
{
NSEntityDescription *relatedEntity = relationship.destinationEntity;
NSManagedObjectID *testObjectID1 = [self newObjectIDForEntity:relatedEntity referenceObject:@"Some-ID"];
NSLog( @"testObjectID1: %p", testObjectID1 );
NSManagedObjectID *testObjectID2 = [[NSManagedObjectID alloc] init];
NSLog( @"testObjectID2: %p", testObjectID2 );
}
Further, I can pass nil for both the entity and referenceObject to the same result.
Expected Results:
That both testObjectID1 and testObjectID2 would show up deallocated when the method ends.
Actual Results:
When run twice, the method and category produce the following log output:
2013-03-27 16:26:04.533 PCR[7763:1a903] testObjectID1: 0xa69b520
2013-03-27 16:26:04.534 PCR[7763:1a903] testObjectID2: 0xa2dcab0
2013-03-27 16:26:09.382 PCR[7763:1a903] NSManagedObjectID dealloc: 0xa2dcab0
2013-03-27 16:26:11.905 PCR[7763:1a903] testObjectID1: 0xa257cd0
2013-03-27 16:26:11.905 PCR[7763:1a903] testObjectID2: 0xa69b520
2013-03-27 16:26:13.108 PCR[7763:1a903] NSManagedObjectID dealloc: 0xa69b520
So, testObjectID1 is never being released and in fact shows up as a leak in Instruments.
Regression:
Occurs all the time
Notes:
This is an ARC enabled project.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!