iOS 内存管理问题
我知道已经有很多与此相关的问题,并且我已经尝试遵循它们,但我仍然无法弄清楚问题是什么。
我启用了 NSZombiesEnabled,并且收到错误消息:
2011-08-15 23:13:12.368 appName[3926:207] *** -[CFString release]: message sent to deallocated instance 0x4cf4570
如果我在错误后输入 bt,我会收到此堆栈跟踪:
#0 0x00f92657 in ___forwarding___ ()
#1 0x00f92522 in __forwarding_prep_0___ ()
#2 0x00f3804c in CFRelease ()
#3 0x00f5d18d in _CFAutoreleasePoolPop ()
#4 0x007a53eb in -[NSAutoreleasePool release] ()
#5 0x0004e3ee in _UIApplicationHandleEvent ()
#6 0x0125a992 in PurpleEventCallback ()
#7 0x01002944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#8 0x00f62cf7 in __CFRunLoopDoSource1 ()
#9 0x00f5ff83 in __CFRunLoopRun ()
#10 0x00f5f840 in CFRunLoopRunSpecific ()
#11 0x00f5f761 in CFRunLoopRunInMode ()
#12 0x012591c4 in GSEventRunModal ()
#13 0x01259289 in GSEventRun ()
#14 0x00051c93 in UIApplicationMain ()
#15 0x00002739 in main (argc=1, argv=0xbfffefd8) at main.m:14
我假设这一行正在解释问题,但我真的不确定:
#7 0x01002944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
我想我可能会迷失在什么时候应该释放对象。我尝试在每个使用 alloc 的方法末尾执行 [对象释放],然后在 dealloc 方法中我释放了该类的所有属性。
我需要做什么?
I know there are lots of questions to do with this already, and I've tried to follow them but I still can't work out what the problem is.
I've enabled NSZombiesEnabled, and I get the error message:
2011-08-15 23:13:12.368 appName[3926:207] *** -[CFString release]: message sent to deallocated instance 0x4cf4570
If I type bt after the error, I get this stack trace:
#0 0x00f92657 in ___forwarding___ ()
#1 0x00f92522 in __forwarding_prep_0___ ()
#2 0x00f3804c in CFRelease ()
#3 0x00f5d18d in _CFAutoreleasePoolPop ()
#4 0x007a53eb in -[NSAutoreleasePool release] ()
#5 0x0004e3ee in _UIApplicationHandleEvent ()
#6 0x0125a992 in PurpleEventCallback ()
#7 0x01002944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#8 0x00f62cf7 in __CFRunLoopDoSource1 ()
#9 0x00f5ff83 in __CFRunLoopRun ()
#10 0x00f5f840 in CFRunLoopRunSpecific ()
#11 0x00f5f761 in CFRunLoopRunInMode ()
#12 0x012591c4 in GSEventRunModal ()
#13 0x01259289 in GSEventRun ()
#14 0x00051c93 in UIApplicationMain ()
#15 0x00002739 in main (argc=1, argv=0xbfffefd8) at main.m:14
I'm assuming this line is explaining the problem, but I'm really not sure:
#7 0x01002944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
I think I might be getting lost as to when I should be releasing objects. I've tried to do [object release] at the end of every method that uses alloc, and then in the dealloc method I've released all the properties for that class.
What do I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的应用程序中有一个字符串已过度释放。由于释放自动释放池时会出现问题,因此您不小心释放了自动释放的对象。以下是可能导致此问题的示例:
如果没有任何相关代码,我所能做的就是提供该代码作为模式,供您查找代码中的问题。
There is a string in your application that you have over released. Since it is problem when the autoreleasepool is released you are accidentally releasing an autoreleased object. Here is an example of what may cause this:
Without any relevant code all I can do is offer that as pattern for you to look for issues in your code.