如何解决我的应用程序泄漏时使用Qt 4.5? [英] How do I fix my application from leaking when using Qt 4.5?
问题描述
没有对我的代码的任何更改,除非构建对Qt 4.5我在运行我的应用程序时收到以下警告消息:
Without any changes to my code except building against Qt 4.5 I get the following warning message when I run my application:
*** _NSAutoreleaseNoPool(): Object 0x50a1b0 of class NSCFNumber autoreleased with
no pool in place - just leaking
$ b b
我没有在我的代码中使用任何Objective-C,但Qt 4.5使用一个新的基于Cocoa的后端而不是Carbon。
I am not using any Objective-C in my code but Qt 4.5 is using a new Cocoa based back end instead of Carbon.
我不知道以解决此错误消息。任何人都有线索?
I am not sure how to address and fix this error message. Anyone have a clue?
推荐答案
一般来说,当你的代码看到这个问题时, c $ c> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 之前和 [pool release];
之后。你可以在 _NSAutoreleaseNoPool
函数上设置一个断点,只需查找堆栈爬行就可以看到有问题的代码。请记住, -autorelease
在Cocoa中随处可见,因此它可能不是对触发它的Qt代码中的autorelease的特定调用。
Generally, when you see this problem in your code, you bracket the offending code block with NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
before and [pool release];
after. You can set a breakpoint on the _NSAutoreleaseNoPool
function and just look up the stack crawl to see what the offending code is. Keep in mind that -autorelease
is used everywhere in Cocoa, so it might not be a specific call to autorelease in Qt's code that's triggering it.
然而,因为这是Qt的代码,这样做,并且,最后我检查,Qt / Cocoa仍然是一个进展中的工作,你应该可能只提交一个错误报告与错误和堆栈抓取他们,并等待他们解决它。
However, since this is Qt's code that's doing this, and, last I checked, Qt/Cocoa was still very much a work in progress, you should probably just submit a bug report with the error and a stack crawl to them, and wait for them to fix it.
这篇关于如何解决我的应用程序泄漏时使用Qt 4.5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!