断点指出“objc_autoreleaseNoPool” [英] Breakpoint pointing out "objc_autoreleaseNoPool"

查看:172
本文介绍了断点指出“objc_autoreleaseNoPool”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在调试一个应用程序,因为它的应用程序如此发布,我启用了All Exceptions的通用断点。从那时起,每次运行应用程序时,控制台都会打印:

So I'm debugging an app in preperation for its app so release, and I enabled a universal breakpoint for "All Exceptions". Since then, everytime I run the app, the console prints:


Catchpoint 2(throw)待定断点1 - objc_exception_throw已解决

Catchpoint 2 (throw)Pending breakpoint 1 - "objc_exception_throw" resolved

objc [11765]:类__NSCFLocale的对象0x8f18ff0自动释放,没有池到位 - 只是泄漏 - 在objc_autoreleaseNoPool()中断以调试

objc [11765]:类__NSCFNumber的对象0x8f190a0自动释放,没有池到位 - 只是泄漏 - 在objc_autoreleaseNoPool()上中断以进行调试

objc [11765]:类__NSCFLocale的对象0x8f1fef0自动释放,没有池到位 - 只是泄漏 - 在objc_autoreleaseNoPool()中断以调试

字面打印3次。我不知道这意味着什么,但看起来很糟糕。任何建议都将不胜感激。

Literally printed 3 times. I have no idea what this means but it looks bad. Any advice would be appreciated.

推荐答案

新信息

我通过创建一个混合自动释放方法来确定我的问题所在。

I determined where my issue lies by creating a swizzled autorelease method.

除非你知道自己在做什么,否则我不建议这样做,不过这是什么我发现了。

I dont recommend doing that unless you know what you are doing, however this is what I found out.

+ (void) load; //Method is called outside the original autorelease pool.
+ (void) initialize; // Method is called outside the original autorelease pool.

NSThread创建自己的线程,被调用的方法应该包含在自动释放池中。

NSThread creates its own thread, the called method should be wrapped in an autorelease pool.

Grand Central Dispatch在使用dispatch _...命令时负责调整自动释放池。但是,当您手动调度时。您可能希望将其包装在自动释放池中。

Grand Central Dispatch takes care of adapting over the autorelease pool when using the "dispatch_..." commands. however, when you dispatch manually. you may want to wrap it in an autorelease pool.

此外,ARC不会让您知道自动释放将在池外发生。

Also, ARC does not handle letting you know that an autorelease will happen outside a pool.

因此,如果您使用ARC并且知道您将在自动释放池之外。你无能为力。你会想要避免所有方便的方法。

Therefore if you are using ARC and know that you will be outside the autorelease pool. And there is nothing you can do about that. You will want to avoid all convenience methods.

使用它。

[[NSString alloc] initWithFormat:@"%@",myObject];

而不是

[NSString stringWithFormat:@"%@",myObject];

这将允许弧系统保留和释放,但是方便方法完成的基础自动释放将被跳过,因为你没有使用便利方法。

this will allow the arc system to retain and release, but the underlying autorelease done by the convenience method will be skipped as you will not have used the convenience method.

希望有所帮助。

原创回答

好的,我觉得这个问题没有得到足够的详细解答。

Ok, I dont feel this question was answered with enough detail.

消息正在呈现

objc[1310]: Object 0x34f720 of class SimpleKeychain autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

调试器指出一个可能的断点,它将帮助你调试情况。现在虽然这个断点确实没有帮助调试情况。我认为知道如何将该断点添加到调试器中非常重要,因此我花时间修补它(在搜索互联网并找不到任何内容之后),直到我得到它来解决该错误。

The debugger is pointing out a possible breakpoint that will help you debug the situation. Now while this breakpoint really did little to help debug the situation. I think that it is important to know how to add that breakpoint to the debugger and so I spent the time tinkering with it (after scouring the internet and finding nothing) until I got it to break on that error.

令人讨厌的是,所有错误的中断都没有捕获到这一点,但这里是将断点添加到调试器的步骤。

It is kind of annoying that break on all errors does not catch this, but here are the steps to add the breakpoint to the debugger.

你要做的第一件事是选择调试器的断点导航器

first thing you want to do is select the debugger's breakpoint navigator

点击此标签

然后你看向导航器窗格的底部并按下加号按钮

next you look toward the bottom of the navigator pane and press the Plus button

这将允许您手动添加断点。

This will allow you to manually add a breakpoint.

我选择了一个C ++断点并输入了消息名称放入名称文本字段。

I selected a C++ breakpoint and entered the message name into the name text field.

添加此异常之后确实会中断。

after adding this exception it did in fact break.

然而,这可能是也可能不是作为客观的开发人员对您有用。这突破了汇编代码。

However this may or may not be useful to you as an objective c developer. This broke into the Assembly code.

不幸的是,它只在线程的调用堆栈上显示了这一点。

Unfortunately it only showed this point on the call stack for the thread.

事实证明自动回复问题是因为在dispatch_once调用中有一个名为autorelease的类。并进一步调查显示+(空)负荷;在其他任何事情之前调用类的方法。这是通过call_load_methods函数完成的,并且在main方法的线程之外。

And it turned out that the autorelease problem was because a class called autorelease in a dispatch_once call. and further investigation revealed that the +(void)load; method on the class was called before anything else. this is done via the call_load_methods function and is outside the thread on the main method.

为了解决这个问题,我只是在通话中添加了自动释放池包装器。

to correct this, I merely added the autorelease pool wrapper around the call.

另一种解决方案可能是在+(void)加载中添加自动释放池;方法。但这对我的用途来说已经足够了。

another solution may be to add the autorelease pool inside the +(void)load; method. but this was sufficient for my uses.

注意:我在这里将帖子添加到帖子中因为我不喜欢找到问题并且无法计算出所有答案的路径。如果调试器告诉您向列出的函数添加断点,那么应该在某处获取某些信息以获取该信息。希望这会降低那些试图找到这个答案的人的挫败感。

这篇关于断点指出“objc_autoreleaseNoPool”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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