【发布时间】:2010-12-29 20:21:48
【问题描述】:
我有一个正在重构的应用程序,我刚刚实现了多线程,以便 UI 可以运行得更流畅。在 iphone 模拟器中,我没有任何泄漏,但在运行 iOS 4.2 的 iPhone 3G 上进行测试时,我得到了内存泄漏。我已经做了很多寻找使用操作队列实现自动释放池的正确方法,我们将不胜感激。
我已经在我的视图控制器中创建了一个 nsoperationqueue
- (void)loadData
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSOperationQueue *queue = [NSOperationQueue new]; // creates multithread for loading data without slowing UI
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(firstRun) object:nil];
[queue addOperation:operation];
[operation release];
[queue release];
[pool release];
}
【问题讨论】:
标签: iphone xcode nsoperationqueue nsautoreleasepool