performSelectorInBackground 导致内存泄露的解决方法

程序中起了一个线程来调用某updataData的方法


[xxAdManager performSelectorInBackground: @selector(updateData) withObject:nil];


结果出现了内存泄露的提示:
class xxxx autoreleased with no pool in place - just leaking

解决方法:
在updataData方法中最前端和最后端增加AutoReleasePool即可

+(void) updateData
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
xxxx
    
    [pool release];
}


你可能感兴趣的:(Class)