Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the memory leaks in my for ... in loop with addObject

There seem to be some memory leaks in the following loop:

NSMutableArray *array1 = [[NSMutableArray alloc] init];
for(SomeClass *someObject in array2){    //has already been populated;
    if (someObject.field == desiredValue){
        [array1 addObject:someObject];
    }
}
//EDIT:
//use array1 for very secret operations
[array1 release];

Any ideas why?

like image 277
magtak Avatar asked Nov 13 '22 15:11

magtak


1 Answers

Are you releasing all your retained properties in SomeClass of yours? Make sure in dealloc release all retained properties.. Make sure your SomeClass is leak free..

like image 151
Krishnabhadra Avatar answered Dec 30 '22 08:12

Krishnabhadra