如何打破__NSAutoreleaseNoPool [英] How to break on __NSAutoreleaseNoPool

查看:121
本文介绍了如何打破__NSAutoreleaseNoPool的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


*** __NSAutoreleaseNoPool():NSEvent类的对象0x1961180自动释放,没有池到位 - 在运行期间泄漏


警告,不知道原因是什么。 Cursory Googles表示这是Xcode可以打破的符号,但是通过运行>管理断点>添加符号断点将其添加为符号断点,或者简单地通过断点管理窗口,导致断点与旁边的断点而不是一个支票,我认为这是一个无法找到的符号。



我尝试添加符号__NSAutoreleaseNoPool两个下划线,一个下划线,现在我只是感到愚蠢。这些错误继续被记录下来,没有断点被击中。任何用于打破Obj-C符号或调试的指针都将不胜感激。



解决方案

要真正回答你的问题,看看 NSDebug.h 。在那里你会发现这是一个注释:

  ENV的名称。 VARIABLE DEFAULT SET TO ... 
NSDebugEnabled否YES
NSZombieEnabled否是
NSDeallocate僵尸否是
NSHangOnUncaughtException否是

更远的是这些评论:

  //调试器中用作有趣断点的函数
// void __NSAutoreleaseNoPool(void * object);
//调用记录Y类的对象X自动释放,没有
//池到位 - 只是泄漏消息。如果环境
//变量名为NSAutoreleaseHaltOnNoPool的字符串为
//值YES,该函数将自动中断
//调试器(或终止进程)。

// void __NSAutoreleaseFreedObject(void * freedObject);
//当一个以前释放的对象将被一个自动释放池释放
//时调用。如果名为
//NSAutoreleaseHaltOnFreedObject的环境变量设置为字符串值
//YES,该函数将自动中断调试器
//(或终止进程)。

所以你真的不需要设置这些断点;只需设置适当的环境变量。你可以从你的例子或者在Xcode 4中,您可以编辑方案的运行部分并将其设置在那里,这就是我所做的,它的工作原理很好。 / p>

I'm getting peppered with

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

warnings during run-time and have no idea what the cause is. Cursory Googles indicate that this is a symbol I can break on with Xcode, but adding it as a symbolic breakpoint via Run>Manage Breakpoints>Add Symbolic Breakpoint, or simply via the breakpoints management window, results in a breakpoint with a - next to it instead of a check, which I take to mean it's a symbol that can't be found.

I've tried adding the symbol "__NSAutoreleaseNoPool" with two underscores, one underscore, and now I'm just feeling stupid. The errors continue to get logged and no breakpoints get hit. Any pointers for breaking on Obj-C symbols or debugging this would be appreciated.

[EDIT: after maybe 10 (10 more, so a couple dozen total, including at least two Xcode restarts) runs I got "Pending breakpoint 9 - "__NSAutoreleaseNoPool" resolved" printed to my console and the breakpoint started working. Is there any way to force a pending breakpoint to actually resolve?]

解决方案

To actually answer your question, look in NSDebug.h. There you will find a comment of which this is part:

NAME OF ENV. VARIABLE                  DEFAULT  SET TO...
NSDebugEnabled                            NO    "YES"
NSZombieEnabled                           NO    "YES"
NSDeallocateZombies                       NO    "YES"
NSHangOnUncaughtException                 NO    "YES"

and farther down are these comments:

// Functions used as interesting breakpoints in a debugger
// void __NSAutoreleaseNoPool(void *object);
        // Called to log the "Object X of class Y autoreleased with no
        // pool in place - just leaking" message.  If an environment
        // variable named "NSAutoreleaseHaltOnNoPool" is set with string
        // value "YES", the function will automatically break in the
        // debugger (or terminate the process).

// void __NSAutoreleaseFreedObject(void *freedObject);
        // Called when a previously freed object would be released
        // by an autorelease pool.  If an environment variable named
        // "NSAutoreleaseHaltOnFreedObject" is set with string value
        // "YES", the function will automatically break in the debugger
        // (or terminate the process).

So you don't really need to set these breakpoints; just set the appropriate environment variables. You can do the latter either from your e.g. .bashrc or in Xcode 4 you can edit the "Run" section of your "scheme" and set them there -- that's what I do, and it works just fine.

这篇关于如何打破__NSAutoreleaseNoPool的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆