PerformSelectorInBackground leaking on device
- by Oysio
While it seems to not pose a problem on the simulator, using performSelectorInBackground on the device causes memory leaks. Or at least that's what Instruments indicates. Looking at the code I don't have a single clue what the cause could be.
I tried to strip the affected code to a bare minimum but still strangely Instruments keeps showing a leak every time this piece of code is executed.
Anything unusual going on here?
//In viewcontrollerA:
-(void)mainLoop
{
[self.viewControllerB performSelectorInBackground:@selector(calculateTotals) withObject:nil];
//This gives the same problem
//[NSThread detachNewThreadSelector:@selector(calculateTotals) toTarget:self.viewControllerB withObject:nil];
//UI stuff ...
}
//viewControllerB:
-(void)calculateTotals
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//Heavy calculations ...
[pool release];
}