NSNumber Leaking memory inside a for loop – started occurring at Xcode Instruments version 4.1 on OSX Lion – this is leaking when executed on device profile with instruments. Any ideas appreciated.
int currentActivityScore = [self.activityScore intValue];
int deltaCriteriaScore = [[segmentItemArray objectAtIndex:3] intValue];
int newActivityScore = currentActivityScore + deltaCriteriaScore;
self.activityScore = [NSNumber numberWithInt:newActivityScore];
i tried this code too, still getting a leak!!!
int currentActivityScore = [self.activityScore intValue];
int deltaCriteriaScore = [[segmentItemArray objectAtIndex:3] intValue];
int newActivityScore = currentActivityScore + deltaCriteriaScore;
NSNumber *newActivityScoreNumber = [[NSNumber alloc] initWithInt:newActivityScore];
self.activityScore = newActivityScoreNumber;
[newActivityScoreNumber release];
Assuming that
activityScoreeither retains or copies its values, then I think your code is okay.It’s not unheard of for Instruments to give false-positives (or miss genuine leaks). Consider it a pointer to code to double-check rather than a guarantee of a leak.