PerformSelectorInBackground leaking on device
Posted
by Oysio
on Stack Overflow
See other posts from Stack Overflow
or by Oysio
Published on 2010-05-24T01:07:40Z
Indexed on
2010/05/24
1:10 UTC
Read the original article
Hit count: 397
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];
}
© Stack Overflow or respective owner