I have a really large loop in my program, and I use a lot of temporary and instance variables. As my loop keeps running, the program uses up more and more memory until it crashes. Can I get some advice on how to do correct memory management in this situation? My main question is, why is the following code wrong?
Here is the code that is causing the leak:
(void) processTrackValues:(NSMutableArray*) tags {
NSImage* trackArt = [tags objectAtIndex:5];
NSMutableArray* tempArtArray = [[NSMutableArray alloc] init];
[tempArtArray addObject:trackArt];
[tempArtArray release];
}
I also tried:
(void) processTrackValues:(NSMutableArray*) tags {
NSImage* trackArt = [tags objectAtIndex:5];
NSMutableArray* tempArtArray = [[NSMutableArray alloc] init];
[tempArtArray addObject:trackArt];
[trackArt release];
[tempArtArray release];
}