i been cracking my head over this memory leak..
my datasource is mutabledictionary..that i load in the viewdidload. if i dont retain it. i dont have access it it in cellforrowatindexpath. but when i retain it.. it shows up as a memory leak in instruments. i have tried so many different variations.. doesnt seem to get it right.
here is the code the leak is in "dict" and "plistPath"
` - (void)viewDidLoad { [super viewDidLoad];
self.navigationController.navigationBarHidden = NO;
self.title = @"Messages & Lists";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
[plistPath release];
plistPath = [documentsDirectory stringByAppendingPathComponent:@"general.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
[dict release];
if ( [fileManager fileExistsAtPath:plistPath] ) {
dict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath] ;
} else {
dict = [NSMutableDictionary dictionaryWithCapacity:1];
[dict setObject:@"NO" forKey:@"busyStatus"];
[dict setObject:@"NO" forKey:@"replyToAll"];
[dict setObject:@"NO" forKey:@"replyToList"];
[dict setObject:@"NO" forKey:@"dontReplyToList"];
[dict writeToFile:plistPath atomically:YES];
}
[tableData release];
tableData = [[NSMutableDictionary alloc] init];
[tableData setObject:[NSArray arrayWithObjects:@"Help",@"Set Default Message",@"Reply To All",[dict objectForKey:@"replyToAll"],nil] forKey:@"1"];
[tableData setObject:[NSArray arrayWithObjects:@"Reply to a List",[dict objectForKey:@"replyToList"],@"List of Contacts",nil] forKey:@"2"];
[tableData setObject:[NSArray arrayWithObjects:@"Don't reply to List",[dict objectForKey:@"dontReplyToList"],@"List of Contacts",nil] forKey:@"3"];
[dict retain];
[plistPath retain];
}
`
there is no leak the first time the view loads. but if i got back. and then load the view again it leaks.
thanks in advance for anyone who can help me out.