How do I fix my application from leaking when using Qt 4.5?

隐身守侯 提交于 2020-02-04 04:00:09

问题


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

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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/865269/how-do-i-fix-my-application-from-leaking-when-using-qt-4-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!