【问题标题】:*** __NSAutoreleaseNoPool(): Object 0x926d620 of class NSPathStore2 autoreleased with no pool in place - just leaking*** __NSAutoreleaseNoPool():NSPathStore2 类的对象 0x926d620 自动释放,没有适当的池 - 只是泄漏
【发布时间】:2012-07-24 04:06:25
【问题描述】:

我的应用程序是启用 ARC 的。

在应用程序委托中我写了一个代码

[self performSelectorInBackground:@selector(initializeAnimationImageArrays) withObject:nil];

而我的方法是

- (void)initializeAnimationImageArrays
{
    NSArray *animationArray = [NSArray arrayWithObjects:
           [UIImage imageNamed:@"1.png"],
           [UIImage imageNamed:@"2.png"],
           [UIImage imageNamed:@"3.png"],
           nil];
}

我看到了一些错误信息,如下所示

*** __NSAutoreleaseNoPool(): Object 0x926d620 of class NSPathStore2 autoreleased with no pool in place - just leaking

我通过如下修改方法解决了这个问题。

@autoreleasepool
{ 
   NSArray *animationArray = [NSArray arrayWithObjects:
          [UIImage imageNamed:@"1.png"],
          [UIImage imageNamed:@"2.png"],
          [UIImage imageNamed:@"3.png"],
          nil];
}

谁能给我解释一下,在这种情况下发生了什么。

【问题讨论】:

    标签: iphone ios automatic-ref-counting nsautoreleasepool


    【解决方案1】:

    它说您没有自动释放池来管理自动释放的对象。 默认情况下,主线程将拥有其自动释放池。 当你创建一个线程时,你必须自己创建一个自动释放池。

    【讨论】:

    • 我在ipad 4.3模拟器中发现了这个问题。在5.0和5.1没有问题。
    • 有趣。让我们找出IOS中添加了什么来消除警告。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多