iphone - 尝试弹出未知的自动释放池

标签 iphone core-data

有人知道这个错误是什么意思吗? *** 尝试弹出未知的自动释放池

我在使用 NSOperationQueue 中的 NSOperations 的应用程序中看到了这一点。每个操作都有它自己的自动释放池。由于每个操作都会解析 xml 并将信息推送到 Core Data,因此我会定期“耗尽”自动释放池并重新创建它。如果我不排空池中的水,我就不会看到这些错误。

更新: 这是我的代码:

在我的 NSOperation 的主体中,我分配池并将其分配给“分配”属性,如下所示:

self.downloadAndParsePool = [[NSAutoreleasePool alloc] init];

在我的主程序结束时,我像这样发布它:

[self.downloadAndParsePool release];
self.downloadAndParsePool = nil;

如果该操作进行了大量解析并插入到 Core Data 中,它将定期调用我的排出方法:

- (void) drainAutoreleasePool
{
    // drain and re-create autorelease pool...this method is called periodically to keep memory down during parsing of large trees
    if (self.downloadAndParsePool)
    {
        [self.downloadAndParsePool drain];
        self.downloadAndParsePool = [[NSAutoreleasePool alloc] init];
    }
}

最佳答案

这个问题似乎是由于在分配池的方法之外调用了 Drain 造成的,即使在同一线程上也是如此。这是 NSAutoreleasePool 类引用的内容。

You should always drain an autorelease pool in the same context (invocation of a method or function, or body of a loop) that it was created.

您看到的消息是由您调用rainAutoreleasePool中的drain触发的:

[self.downloadAndParsePool drain];

注意:XMLPerformance 示例应用程序使用相同的定期耗尽池的模式。从iOS4.0开始它也会产生这个消息

关于iphone - 尝试弹出未知的自动释放池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3088978/

相关文章:

iphone - AVMutableVideoComposition 以纵向模式捕获的旋转视频

iOS:调试简单的 UI 滞后(我猜是基于 CoreData)

ios - 在与父实体有关系的子 NSManagedObjectContext 中创建实体

iphone - 基本数组比较算法

ios - Swift - 使用 CoreData 从数据库预加载和更新数据

iphone - iPhone的Objective-C分配变量问题

ios - Xcode 10.3 中缺少模拟器

iphone - iOS 4.0 及更高版本中的相机数码变焦

ios - 如何将不同的页面信息保存到同一个tableviewcell?

iphone - 通过socket.h调用connect()时,使用GSoap返回EHOSTUNREACH