问题:
NSCFString autoreleased with no pool in place - just leaking
解决方案
在你使用非主线程而又使用了autorelease方法就会出现这样的问题
可以这样修改:
例如你原来是这样写的:
- (void)someMethodPerformedInOtherThread
{
// code (for example: [UIColor redColor])
}
改为:
- (void)someMethodPerformedInOtherThread
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// code (for example: [UIColor redColor])
[pool release];
}
NSCFString autoreleased with no pool in place - just leaking
解决方案
在你使用非主线程而又使用了autorelease方法就会出现这样的问题
可以这样修改:
例如你原来是这样写的:
- (void)someMethodPerformedInOtherThread
{
// code (for example: [UIColor redColor])
}
改为:
- (void)someMethodPerformedInOtherThread
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// code (for example: [UIColor redColor])
[pool release];
}
本文解决了一个关于NSCFString在非主线程中使用autorelease方法导致的内存泄漏问题。通过创建并使用NSAutoreleasePool,有效地避免了内存泄漏。
1万+

被折叠的 条评论
为什么被折叠?



