3

我的自动释放池随机使我的应用程序崩溃,这个问题的常见原因是什么?

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x0145ba63 objc_msgSend + 23
1   CoreFoundation                  0x01210a6c CFRelease + 92
2   CoreFoundation                  0x012f2e8a -[__NSArrayM dealloc] + 170
3   CoreFoundation                  0x01210a6c CFRelease + 92
4   CoreFoundation                  0x01235b8d _CFAutoreleasePoolPop + 237
5   Foundation                      0x0005886c __NSFireDelayedPerform + 559
6   CoreFoundation                  0x012dafe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
7   CoreFoundation                  0x012dc594 __CFRunLoopDoTimer + 1220
8   CoreFoundation                  0x01238cc9 __CFRunLoopRun + 1817
9   CoreFoundation                  0x01238240 CFRunLoopRunSpecific + 208
10  CoreFoundation                  0x01238161 CFRunLoopRunInMode + 97
11  GraphicsServices                0x01c2e268 GSEventRunModal + 217
12  GraphicsServices                0x01c2e32d GSEventRun + 115
13  UIKit                           0x002e842e UIApplicationMain + 1160
14  FancyAPint                      0x000029e8 main + 102 (main.m:14)
15  FancyAPint                      0x00002979 start + 53

我知道这是因为一个对象被过度释放,我认为一个对象在自动释放池试图释放它之前被释放是正确的。因此自动释放池试图过度释放一个对象?

4

2 回答 2

13

你的评估是正确的。尝试使用模拟器中的“Zombies”工具运行您的应用程序,或将 NSZombieEnabled 环境变量设置为 YES。这些都将为您提供有关哪些对象被过度释放的更多信息。

于 2011-01-17T11:38:20.707 回答
0

这将是因为额外的内存释放。不要释放在自动释放池中分配的对象,并从拥有自己内存的对象中初始化。这可能是这背后的一个原因,因为我也面临这个问题。

于 2011-01-17T13:08:38.190 回答