[Qt-interest] Memory leak in Qt Demo file. (Qt 4.7 Cocoa)

Louis Rodriguez hellospam at me.com
Sat Nov 13 23:57:07 CET 2010


Hello,

I built and opened this demo file in X-Code:

QT/Examples/MacMainWindow

and upon running and quitting the app, then looking in the console/debug, I noticed that this Demo File has a memory leak:

This is what I see:

2010-11-13 14:50:28.953 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0x1c2d0b0 of class NSImage autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.954 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0x1c2d0b0 of class NSImage autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.954 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0x1c24eb0 of class QCocoaMenu autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.955 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0xa09f26cc of class NSCFString autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.955 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0x1c2aa50 of class NSImage autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.955 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0x1c2ab40 of class NSImage autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.955 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0x1c2ce50 of class NSCFString autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.955 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0x1c2d070 of class NSCFString autoreleased with no pool in place - just leaking
2010-11-13 14:50:28.956 macmainwindow[17134:a0f] *** __NSAutoreleaseNoPool(): Object 0xa09dd34c of class NSCFString autoreleased with no pool in place - just leaking

and this is the code, that if I comment out the creation of the SearchWrapper (and all its references) , I do not see the memory leaks (and obviously do not see the searchwrapper in my app:

    s = new SearchWidget(this);

So I know it is somewhere in this code:

SearchWidget::SearchWidget(QWidget *parent)
    : QMacCocoaViewContainer(0, parent)
{
    // Many Cocoa objects create temporary autorelease objects,
    // so create a pool to catch them.
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    // Create the NSSearchField, set it on the QCocoaViewContainer.
    NSSearchField *search = [[NSSearchField alloc] init];
    setCocoaView(search);

    // Use a Qt menu for the search field menu.
    QMenu *qtMenu = createMenu(this);
    NSMenu *nsMenu = qtMenu->macMenu(0);
    [[search cell] setSearchMenuTemplate:nsMenu];

    // Release our reference, since our super class takes ownership and we
    // don't need it anymore.
    [search release];

    // Clean up our pool as we no longer need it.
    [pool release];
}


Would this be considered a bug I should report?

I am Qt 4.7.1 on OS X 10.6.5

and does anyone know of a fix, since I would like to use this cocoa SearchField in my app but don't want my customers to experience memory leaks.

thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101113/290be3ef/attachment.html 


More information about the Qt-interest-old mailing list