Xcode:NSZombie 未捕获错误
可能的重复:
Xcode malloc 错误
我的游戏有时会由于此消息而崩溃:
malloc: *** error for object 0x65cfcd4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
因此,按照建议,我运行了分配工具尝试找到泄漏的仪器并启用 NSZombie 检测。它说它正在执行期间检查僵尸。
但应用程序崩溃了,什么也没有捕获。
僵尸有什么理由不抓住它?
谢谢。
Possible Duplicate:
Xcode malloc error
My game crashed sometimes due to this message:
malloc: *** error for object 0x65cfcd4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
So as advised, I ran the Allocations tool in instruments to try find the leak and tecked Enable NSZombie Detection. It said it was checking for zombies during execution.
But the app crashes and NOTHING is caught.
Any reason why a zombie wouldn't catch it?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
建议不要启用僵尸,僵尸仅适用于 Objective-C,
malloc
、realloc
和free
是分配内存的 C 方式,僵尸工具不会捕获这些错误。在malloc_error_break
中设置断点并查看堆栈跟踪以解决错误。The advise isn't to enable zombies, zombies are Objective-C only and
malloc
,realloc
andfree
are the C way of allocating memory, the zombie tool won't catch these errors. Set a breakpoint inmalloc_error_break
and look at the stack trace to resolve the error.不用太花哨,您可以删除所有
免费
调用,看看它是否可以解决问题。如果您的项目规模不是很大,这可能比您将使用的任何“专业工具”都要快。如果它解决了问题,只需将free
调用一一插入,答案就会显而易见。如果您使用 cocos2d,只需删除所有这些“免费”调用即可。 C内存分配很容易出错。
Without getting too fancy, you can remove all your
free
calls and see if it fixes the problem. If your project isn't very large scale, this may be faster than any "professional tool" you will use. If it fixes the issue, just plug thefree
calls one by one and the answer should become apparent.If you use cocos2d, simply delete all those "Free" calls. C memory allocation is easy to get wrong.