Reputation: 1179
I just finished running my application through instruments and I am leaking _NSCFDictionaries out of control. I do not have a @property set up for workoutArray as it is a private instance variable.
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"data.plist"];
NSArray *rawDump = [[NSArray alloc] initWithContentsOfFile:DataPath];
workoutArray = [[NSMutableArray alloc] init];
for (NSDictionary *dict in rawDump){
[workoutArray addObject: dict];
}
[rawDump release];
I release workoutArray in -dealloc
- (void)dealloc {
[workoutArray release];
[managedObjectContext release];
[df release];
[super dealloc];
}
Any help is much appreciated.
Upvotes: 0
Views: 540
Reputation: 25632
As you indicate you run this more than once (on the same instance), then the problem is that you reassign your workoutArray
without releasing the old object. You need to release
the old object before reassigning:
[workoutArray release];
workout Array = [[NSMutableArray alloc] init]; // etc.
As workoutArray
as an ivar is nil by default on the first time, this should always work correctly.
Upvotes: 3