发布新日志

  • [Help]memory leak in simple GUI applicaton‏

    2008-11-18 13:02:12

    Hi:
      These days, i was puzzled by memory leak when i used valgrind to check qt GUI application. Because there were not many available materials to explain why there was memory leak in qt(i meaned the qt GUI). So, i send this mail for getting help.
    Here was a simple example.
    source code:
    #include <QWidget>
    #include <QApplication>

    int main(int argc, char* argv[])
    {
        QApplication app(argc, argv);
      
        QWidget widget;
        widget.show();
      
        return app.exec();
    }

    after i compiled it. i typed command "valgrind --tool=memcheck --leak-check=full ./test" in terminal.
    Then, i got the folloing result:
    ==7729== ERROR SUMMARY: 22 errors from 10 contexts (suppressed: 35 from 1)
    ==7729== malloc/free: in use at exit: 22,222 bytes in 322 blocks.
    ==7729== malloc/free: 3,681 allocs, 3,359 frees, 3,713,807 bytes allocated.
    ==7729== For counts of detected errors, rerun with: -v
    ==7729== searching for pointers to 322 not-freed blocks.
    ==7729== checked 401,848 bytes.
    ==7729==
    ==7729==
    ==7729== 420 (28 direct, 392 indirect) bytes in 1 blocks are definitely lost in loss record 14 of 24
    ==7729==    at 0x401D96E: realloc (vg_replace_malloc.c:429)
    ==7729==    by 0x49DC4D3: (within /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x49DCF3B: (within /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x49DEC97: _XlcCreateLC (in /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x4A00929: _XlcUtf8Loader (in /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x49E57AE: _XOpenLC (in /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x49E589D: _XrmInitParseInfo (in /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x49CF4C0: (within /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x49D0FE7: XrmGetStringDatabase (in /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x49AA863: XGetDefault (in /usr/lib/libX11.so.6.2.0)
    ==7729==    by 0x545237C: _XcursorGetDisplayInfo (in /usr/lib/libXcursor.so.1.0. 2)
    ==7729==    by 0x54525FC: XcursorSupportsARGB (in /usr/lib/libXcursor.so.1.0.2)
    ==7729==
    ==7729== LEAK SUMMARY:
    ==7729==    definitely lost: 28 bytes in 1 blocks.
    ==7729==    indirectly lost: 392 bytes in 14 blocks.
    ==7729==      possibly lost: 0 bytes in 0 blocks.
    ==7729==    still reachable: 21,802 bytes in 307 blocks.
    ==7729==         suppressed: 0 bytes in 0 blocks.
    ==7729== Reachable blocks (those to which a pointer was found) are not shown.
    ==7729== To see them, rerun with: --leak-check=full --show-reachable=yes
    from summary, i got known that the app has lost 28 bytes memory.
    I did not know why? and i was hungering for getting your help.
    Thanks, best wishes.
    From: abcrunning@hotmail.com^_^

数据统计

  • 访问量: 732
  • 日志数: 1
  • 建立时间: 2008-07-21
  • 更新时间: 2008-11-18

RSS订阅

Open Toolbar