[英]Autorelease pool crashing App
My autorelease pool is crashing my app at random, what is the common cause of this problem? 我的自动释放池随机崩溃我的应用程序,这个问题的常见原因是什么?
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
I know this is because an object is being over released, am i correct in thinking an object is being released before the autorelease pool is trying to release it. 我知道这是因为一个对象被过度释放,我认为在自动释放池试图释放它之前正在释放一个对象是正确的。 Therefore the autorelease pool attempts to over release an object? 因此,自动释放池会尝试过度释放对象?
Your assessment is correct. 您的评估是正确的。 Try running your app using the "Zombies" instrument in the simulator, or setting the NSZombieEnabled environmental variable to YES. 尝试使用模拟器中的“Zombies”仪器运行应用程序,或将NSZombieEnabled环境变量设置为YES。 These will both give you more information about what objects are being overreleased. 这些将为您提供有关哪些对象被过度释放的更多信息。
This will be because of extra memory releases. 这将是因为额外的内存释放。 Do not release the object which is being allocated inside auto-release pool and is inited from object which has its own memory. 不要释放在自动释放池中分配的对象,并从具有自己的内存的对象中提取。 This may the one reason behind this as i also faced this problem. 这可能是我背后的一个原因,因为我也遇到了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.