Instruments false positives

I have been able to get rid of reported memory leaks in Instruments not by fixing a leak but by adding some lines (like releasing a previous nil object) that convinced Instruments it is not a leak.

But I am stuck are some I cannot stop Instruments from reporting. It reports a leak in this code

if(expr.length>0)
{	// add previous Atomic
	Atomic *atom = [[Atomic alloc] initWithString:[string substringWithRange:expr] isNumber:aNum];
	[exprTokens addObject:atom];
	[atom release];
}

}

and it underlines the substringWithRange method. I changed code to explicitly release atom and I assumed substringWithRange would return an autoreleased new string. I am aware Instruments tells you where the leaked object is created and not where it is leak, but only things created here are atom and a sub string and atom is released immediately.

The initWithString method might do it, but I don't find anything there. Also, while running instruments, this code is 8542 times (I am pretty sure always in the same context) and Instruments says it only leaks 61 times.

I don't now if there is misunderstanding are a code problem?

Answered by OSParticulas in 793913022

Embarrassingly, I found a solution. Instruments was indeed correct about a leak, but not much help it finding why. After looking at the same code for long time I found I had misspelled dealloc as delloc so it was never called (as the code suggested it should). After correcting the spelling, that leak (as several others too) went away.

I suppose I should convert from non-ARC to ARC, but the thought if converting over 20 years of (legacy) coding, sounds like a lot of work. I might try when I retire next year.

Embarrassingly, I found a solution. Instruments was indeed correct about a leak, but not much help it finding why. After looking at the same code for long time I found I had misspelled dealloc as delloc so it was never called (as the code suggested it should). After correcting the spelling, that leak (as several others too) went away.

I suppose I should convert from non-ARC to ARC, but the thought if converting over 20 years of (legacy) coding, sounds like a lot of work. I might try when I retire next year.

Instruments false positives
 
 
Q