The following code in my function (run in a loop) is causing my program to use more and more memory until it crashes. What am I doing wrong?
- (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];
}
Edit: Here is more information on the surrounding code. I have also added more code to the sample for a bigger picture.
trackArt
is anNSImage
pointer to one of the arguments to this function.- The
NSImage
object thattrackArt
points to is created outside of this function. - I am allocating and releasing
tempArtArray
each iteration of the loop (since the function is called for each iteration of the loop)