I am using Instrument leaks tools to check leaks in the code.
//MyClass.h
@property (nonatomic, retain) NSMutableArray *marrProperty;
//MyClass.m
NSSortDescriptor *createdTime = [[NSSortDescriptor alloc] initWithKey:@"createdTime" ascending:NO selector:@selector(compare:)];
NSArray *sortedArray = [self.anManagedObj.aRelationships sortedArrayUsingDescriptors:[NSArray arrayWithObject:createdTime]];
[createdTime release];
NSMutableArray *marr = [[NSMutableArray alloc] initWithArray:sortedArray];
self.marrProperty = marr;
[marr release];
After checking with the leaks tool in Instrument, I was told the leaks happened in the following code:
NSMutableArray *marr = [[NSMutableArray alloc] initWithArray:sortedArray];
self.marrProperty = marr;
I don’t know why, because I just alloc and release well.
Instruments is showing you were the leaked object was allocated, not where it was leaked.
You need to find the extra
retain. You can use Instruments to do that; the Allocations instrument can be configured to track retain/release events.This will likely be helpful.