I just spent a lot of time debugging a dumb mistake, (releasing a variable that I hadn't allocated) and wondered if there's a way to have XCode's Analyze warn me next time. The code was something like this:
@synthesize alfa, beta;
…
NSString *temp1 = [[NSString alloc] initWithString:@"AlfaText];
self.alfa = temp1;
[temp1 release];
NSString *temp2 = @"BetaText";
self.beta = temp2;
[temp2 release]
The last statement is (obviously?) a bug. Analyze seems to do a good job of reporting when you have too few [release]s, and having too many seems to be just as analyzable. Is there something that can be turned on that I'm missing?
If the static analyzer didn't catch that, please file a bug. It really should have.
If you convert your projects to use ARC, both the lack of writing retain/release at all combined with the better analysis performed by the compiler will lead to many fewer memory management bugs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With