Results 1 to 4 of 4

Thread: Qt Memory manager

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Qt Memory manager

    I'd like to track memory leaks in my application.

    Anybody ever coded a Qt MemoryManager class?

    Thanks.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt Memory manager

    try to use valgrind on Linux.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Memory manager

    I was familiar with mcheck of libc. (http://www.gnu.org/software/libc/man...tion-Debugging)

    I try valgrid with my project but I am a little confused.
    I found just a memory leaky that I made in my code. But there is a lot of memory leaky in the Qt library

    Qt Code:
    1. ==6190== Memcheck, a memory error detector.
    2. ==6190== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
    3. ==6190== Using LibVEX rev 1884, a library for dynamic binary translation.
    4. ==6190== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
    5. ==6190== Using valgrind-3.4.1-Debian, a dynamic binary instrumentation framework.
    6. ==6190== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
    7. ==6190== For more details, rerun with: -v
    8. ==6190==
    9. ==6190==
    10. ==6190== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 163 from 4)
    11. ==6190== malloc/free: in use at exit: 246,896 bytes in 5,239 blocks.
    12. ==6190== malloc/free: 267,157 allocs, 261,918 frees, 48,167,856 bytes allocated.
    13. ==6190== For counts of detected errors, rerun with: -v
    14. ==6190== searching for pointers to 5,239 not-freed blocks.
    15. ==6190== checked 910,728 bytes.
    16. ==6190==
    17. ==6190== 2 bytes in 1 blocks are definitely lost in loss record 2 of 127
    18. ==6190== at 0x4025092: calloc (vg_replace_malloc.c:397)
    19. ==6190== by 0x4D1AA92: _hb_alloc (harfbuzz-impl.c:41)
    20. ==6190== by 0x4D1AF81: _HB_OPEN_Load_Device (harfbuzz-open.c:1318)
    21. ==6190== by 0x4D14D29: Load_Anchor (harfbuzz-gpos.c:639)
    22. ==6190== by 0x4D153AE: Load_MarkBasePos (harfbuzz-gpos.c:2040)
    23. ==6190== by 0x4D19875: _HB_GPOS_Load_SubTable (harfbuzz-gpos.c:5801)
    24. ==6190== by 0x4D1CA35: _HB_OPEN_Load_LookupList (harfbuzz-open.c:458)
    25. ==6190== by 0x4D1A93A: HB_Load_GPOS_Table (harfbuzz-gpos.c:141)
    26. ==6190== by 0x4D1F27C: HB_NewFace (harfbuzz-shaper.cpp:988)
    27. ==6190== by 0x4D24343: qHBNewFace(void*, HB_Error (*)(void*, unsigned int, unsigned char*, unsigned int*)) (qharfbuzz.cpp:154)
    28. ==6190== by 0x4478B06: QFreetypeFace::getFace(QFontEngine::FaceId const&) (qfontengine_ft.cpp:238)
    29. ==6190== by 0x4478FD9: QFontEngineFT::init(QFontEngine::FaceId, bool, QFontEngineFT::GlyphFormat) (qfontengine_ft.cpp:644)
    30. ==6190==
    31. ==6190==
    32. ==6190== 148 (128 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 65 of 127
    33. ==6190== at 0x4026FDE: malloc (vg_replace_malloc.c:207)
    34. ==6190== by 0x4B379D6: (within /usr/lib/libfontconfig.so.1.3.0)
    35. ==6190== by 0x4B383C7: (within /usr/lib/libfontconfig.so.1.3.0)
    36. ==6190== by 0x4B384DE: (within /usr/lib/libfontconfig.so.1.3.0)
    37. ==6190== by 0x4B3DFBE: (within /usr/lib/libfontconfig.so.1.3.0)
    38. ==6190== by 0x5263EC3: (within /usr/lib/libexpat.so.1.5.2)
    39. ==6190== by 0x5264C10: (within /usr/lib/libexpat.so.1.5.2)
    40. ==6190== by 0x52665EE: (within /usr/lib/libexpat.so.1.5.2)
    41. ==6190== by 0x5266CE6: (within /usr/lib/libexpat.so.1.5.2)
    42. ==6190== by 0x525D68B: XML_ParseBuffer (in /usr/lib/libexpat.so.1.5.2)
    43. ==6190== by 0x4B3BEFD: FcConfigParseAndLoad (in /usr/lib/libfontconfig.so.1.3.0)
    44. ==6190== by 0x4B3C245: FcConfigParseAndLoad (in /usr/lib/libfontconfig.so.1.3.0)
    45. ==6190==
    46. ==6190==
    47. ==6190== 156 (36 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 66 of 127
    48. ==6190== at 0x4026FDE: malloc (vg_replace_malloc.c:207)
    49. ==6190== by 0x51A3548: nss_parse_service_list (nsswitch.c:547)
    50. ==6190== by 0x51A3E25: __nss_database_lookup (nsswitch.c:134)
    51. ==6190== by 0x803AF5B: ???
    52. ==6190== by 0x803BCBE: ???
    53. ==6190== by 0x5149811: getpwnam_r@@GLIBC_2.1.2 (getXXbyYY_r.c:253)
    54. ==6190== by 0x4F1FE71: (within /usr/lib/libglib-2.0.so.0.2000.1)
    55. ==6190== by 0x4F21924: g_get_home_dir (in /usr/lib/libglib-2.0.so.0.2000.1)
    56. ==6190== by 0x7FFF524: ORBit_option_parse (in /usr/lib/libORBit-2.so.0.1.0)
    57. ==6190== by 0x800600F: CORBA_ORB_init (in /usr/lib/libORBit-2.so.0.1.0)
    58. ==6190== by 0x7FBF66E: gconf_orb_get (in /usr/lib/libgconf-2.so.4.1.5)
    59. ==6190== by 0x7FBF7FD: (within /usr/lib/libgconf-2.so.4.1.5)
    60. ==6190==
    61. ==6190==
    62. ==6190== 216 bytes in 1 blocks are definitely lost in loss record 75 of 127
    63. ==6190== at 0x4026FDE: malloc (vg_replace_malloc.c:207)
    64. ==6190== by 0x4BC2012: _XimOpenIM (in /usr/lib/libX11.so.6.2.0)
    65. ==6190== by 0x4BC1E4F: _XimRegisterIMInstantiateCallback (in /usr/lib/libX11.so.6.2.0)
    66. ==6190== by 0x4BA6037: XRegisterIMInstantiateCallback (in /usr/lib/libX11.so.6.2.0)
    67. ==6190== by 0x47B843D: QXIMInputContext::QXIMInputContext() (qximinputcontext_x11.cpp:370)
    68. ==6190== by 0x47B68C0: QInputContextFactory::create(QString const&, QObject*) (qinputcontextfactory.cpp:135)
    69. ==6190== by 0x419C997: QApplication::inputContext() const (qapplication.cpp:4929)
    70. ==6190== by 0x41DCCD4: QWidgetPrivate::inputContext() const (qwidget.cpp:271)
    71. ==6190== by 0x41E23AA: QWidget::inputContext() (qwidget.cpp:290)
    72. ==6190== by 0x419A044: QApplicationPrivate::setFocusWidget(QWidget*, Qt::FocusReason) (qapplication.cpp:2091)
    73. ==6190== by 0x41E691C: QWidget::setFocus(Qt::FocusReason) (qwidget.cpp:5747)
    74. ==6190== by 0x419EF58: QApplication::setActiveWindow(QWidget*) (qapplication.cpp:2442)
    75. ==6190==
    76. ==6190==
    77. ==6190== 1,084 bytes in 29 blocks are possibly lost in loss record 96 of 127
    78. ==6190== at 0x4025092: calloc (vg_replace_malloc.c:397)
    79. ==6190== by 0x4EF320B: g_malloc0 (in /usr/lib/libglib-2.0.so.0.2000.1)
    80. ==6190== by 0x4ADB12B: (within /usr/lib/libgobject-2.0.so.0.2000.1)
    81. ==6190== by 0x4ADB1A5: (within /usr/lib/libgobject-2.0.so.0.2000.1)
    82. ==6190== by 0x4ADD7E7: g_type_init_with_debug_flags (in /usr/lib/libgobject-2.0.so.0.2000.1)
    83. ==6190== by 0x4ADD971: g_type_init (in /usr/lib/libgobject-2.0.so.0.2000.1)
    84. ==6190== by 0x453A8A9: QCleanlooksStylePrivate::lookupIconTheme() const (qcleanlooksstyle.cpp:4399)
    85. ==6190== by 0x453D903: QCleanlooksStyle::standardIconImplementation(QStyle::StandardPixmap, QStyleOption const*, QWidget const*) const (qcleanlooksstyle.cpp:4431)
    86. ==6190== by 0x48463E7: QCleanlooksStyle::qt_metacall(QMetaObject::Call, int, void**) (moc_qcleanlooksstyle.cpp:72)
    87. ==6190== by 0x4DAC9A1: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (qmetaobject.cpp:1522)
    88. ==6190== by 0x4DACF8B: QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) (qmetaobject.cpp:1114)
    89. ==6190== by 0x447A16F: QStyle::standardIcon(QStyle::StandardPixmap, QStyleOption const*, QWidget const*) const (qstyle.cpp:2261)
    90. ==6190==
    91. ==6190==
    92. ==6190== 4,288 bytes in 8 blocks are possibly lost in loss record 114 of 127
    93. ==6190== at 0x4024EFA: memalign (vg_replace_malloc.c:460)
    94. ==6190== by 0x4024FAE: posix_memalign (vg_replace_malloc.c:569)
    95. ==6190== by 0x4F08A02: (within /usr/lib/libglib-2.0.so.0.2000.1)
    96. ==6190== by 0x4F0A1E2: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.2000.1)
    97. ==6190== by 0x4EC389E: g_array_sized_new (in /usr/lib/libglib-2.0.so.0.2000.1)
    98. ==6190== by 0x4EC39B6: g_array_new (in /usr/lib/libglib-2.0.so.0.2000.1)
    99. ==6190== by 0x4F15A8B: g_static_private_set (in /usr/lib/libglib-2.0.so.0.2000.1)
    100. ==6190== by 0x4ED340F: g_get_filename_charsets (in /usr/lib/libglib-2.0.so.0.2000.1)
    101. ==6190== by 0x4ED3480: (within /usr/lib/libglib-2.0.so.0.2000.1)
    102. ==6190== by 0x4F15D2C: g_thread_init_glib (in /usr/lib/libglib-2.0.so.0.2000.1)
    103. ==6190== by 0x4EA369C: g_thread_init (in /usr/lib/libgthread-2.0.so.0.2000.1)
    104. ==6190== by 0x4DD29A9: QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(_GMainContext*) (qeventdispatcher_glib.cpp:231)
    105. ==6190==
    106. ==6190== LEAK SUMMARY:
    107. ==6190== definitely lost: 382 bytes in 4 blocks.
    108. ==6190== indirectly lost: 140 bytes in 11 blocks.
    109. ==6190== possibly lost: 5,372 bytes in 37 blocks.
    110. ==6190== still reachable: 241,002 bytes in 5,187 blocks.
    111. ==6190== suppressed: 0 bytes in 0 blocks.
    112. ==6190== Reachable blocks (those to which a pointer was found) are not shown.
    113. ==6190== To see them, rerun with: --leak-check=full --show-reachable=yes
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt Memory manager

    Thanks,

    Valgrind is Linux only.

    I'd like to track memory leak directly from my Qt C++ code.

    Maybe I can achieve that by overloading new operator.

    I'm surprised nobody did that before.

Similar Threads

  1. How Qt update framebuffer memory
    By nrabara in forum Newbie
    Replies: 0
    Last Post: 25th April 2009, 13:20
  2. Memory debugging in windows
    By txandi in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2009, 13:45
  3. Qt like Layout Manager available for .NET platform
    By vkhaitan in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2008, 13:36
  4. Memory leak weirdness
    By Darhuuk in forum General Programming
    Replies: 10
    Last Post: 10th January 2008, 18:51
  5. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.