If I have a variable in my view controler
viewcontroller.m
@interface MemoryTestViewController : UIViewController
{
NSMutableArray *array;
}
@end
in my implementation
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *aux = [[NSMutableArray alloc] initWithCapacity:1];
array = aux;
[aux release];
// Do i have to do array release?
}
Do i have to release my variable array somewhere? Theoricaly i havent allocated that variable…
I testes the memory leaks and even if i dont release anything the instruments doesn’t detect any leak.
No, you don’t need to release. All you do is assign the pointer of
auxto yourarrayvariable.arrayis invalid at the moment where you releaseaux.This is probably not as intended. If you want to work with
array, you’ll have to retain it.