I’m running the Instruments application with the Leaks template and it’s telling me that I have a leak at the line:
NSArray *tempFavs = [tempFavString componentsSeparatedByString:@"|"];
I’ve seen some other people having similar problems but I haven’t seen any solutions. It seems that this array should be autoreleased and I shouldn’t have to worry about it. All of the arrays that I’ve alloc’d are released in the dealloc method. Here’s all of the relevant code:
NSArray *tempFavoritesArray = [appPreferences arrayForKey:[NSString stringWithFormat:@"%@ %@ favorites", server, project]];
favoritesArrayDisplay = [[NSMutableArray alloc] initWithObjects:nil];
cenXsArray = [[NSMutableArray alloc] initWithObjects:nil];
cenYsArray = [[NSMutableArray alloc] initWithObjects:nil];
viewScalesArray = [[NSMutableArray alloc] initWithObjects:nil];
currentPresetsArray = [[NSMutableArray alloc] initWithObjects:nil];
rastersArray = [[NSMutableArray alloc] initWithObjects:nil];
empty = NO;
selected = NO;
if ([tempFavoritesArray count] == 0 || tempFavoritesArray == nil)
{
[favoritesArrayDisplay addObject:@"No favorites saved."];
empty = YES;
}
for (int i=0; i<[tempFavoritesArray count]; i++)
{
NSString *tempFavString = [NSString stringWithString:[tempFavoritesArray objectAtIndex:i]];
NSArray *tempFavs = [tempFavString componentsSeparatedByString:@"|"];
if ([tempFavs count] > 2)
{
[favoritesArrayDisplay addObject:[tempFavs objectAtIndex:0]];
[cenXsArray addObject:[tempFavs objectAtIndex:1]];
[cenYsArray addObject:[tempFavs objectAtIndex:2]];
[viewScalesArray addObject:[tempFavs objectAtIndex:3]];
[currentPresetsArray addObject:[tempFavs objectAtIndex:4]];
[rastersArray addObject:[tempFavs objectAtIndex:5]];
}
}
Has anyone seen this before?
All leaks is telling you is that an object or objects allocated by that line of code are later leaked. It is not showing you the line of code that caused the actual leak, but the line of code that created the allocation that was later leaked.
I.e. you may be over-retaining one of the strings in the
tempFavsarray and leaks is identifying it as a leaked allocation.First, try “build and analyze”. If that doesn’t fix the problem, use the Allocations instrument to figure out exactly which object was leaked and where it was retained/released.