Instance of method leaking, iPhone
Posted
by
Wolfert
on Stack Overflow
See other posts from Stack Overflow
or by Wolfert
Published on 2011-01-06T16:22:59Z
Indexed on
2011/01/06
16:54 UTC
Read the original article
Hit count: 193
The following method shows up as leaking while performing a memory-leaks test with Instruments:
- (NSDictionary*) initSigTrkLstWithNiv:(int)pm_SigTrkNiv SigTrkSig:(int)pm_SigTrkSig SigResIdt:(int)pm_SigResIdt SigResVal:(int)pm_SigResVal {
NSArray *objectArray;
NSArray *keyArray;
if (self = [super init]) {
self.SigTrkNiv = [NSNumber numberWithInt:pm_SigTrkNiv];
self.SigTrkSig = [NSNumber numberWithInt:pm_SigTrkSig];
self.SigResIdt = [NSNumber numberWithInt:pm_SigResIdt];
self.SigResVal = [NSNumber numberWithInt:pm_SigResVal];
objectArray = [NSArray arrayWithObjects:SigTrkNiv,SigTrkSig,SigResIdt,SigResVal, nil];
keyArray = [NSArray arrayWithObjects:@"SigTrkNiv", @"SigTrkSig", @"SigResIdt", @"SigResVal", nil];
self = [NSDictionary dictionaryWithObjects:objectArray forKeys:keyArray];
}
return self;
}
code that invokes the instance:
NSDictionary *lv_SigTrkLst = [[SigTrkLst alloc]initSigTrkLstWithNiv:[[tempDict objectForKey:@"SigTrkNiv"] intValue]
SigTrkSig:[[tempDict objectForKey:@"SigTrkSig"] intValue]
SigResIdt:[[tempDict objectForKey:@"SigResIdt"] intValue]
SigResVal:[[tempDict objectForKey:@"SigResVal"] intValue]];
[[QBDataContainer sharedDataContainer].SigTrkLstArray addObject:lv_SigTrkLst];
[lv_SigTrkLst release];
Instruments informs that 'SigTrkLst' is leaking. Even though I have released the instance? (I know that adding it to the array increments the retainCount by 1 but releasing it twice removes it from the array?)
© Stack Overflow or respective owner