|
From: Jeremy F. <je...@go...> - 2005-02-24 09:42:01
|
In this test, I'm starting Qt designer, hitting "cancel" on the initial
dialogue, then closing the window. It is invoked with "valgrind
--tool=memcheck --leak-check=yes designer".
The current leak checker reports:
[...]
==18142== 3536 bytes in 68 blocks are definitely lost in loss record 425 of 445
==18142== at 0x1B904284: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==18142== by 0x1C0F8132: XftDrawCreate (in /usr/X11R6/lib/libXft.so.2.1.2)
==18142== by 0x1BB2092A: QPixmap::convertFromImage(QImage const&, int) (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18142== by 0x1BB799C2: QImageDrag::decode(QMimeSource const*, QPixmap&) (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18142== by 0x1BBDB68A: QPixmap::fromMimeSource(QString const&) (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18142== by 0x80AC271: (within /usr/lib/qt-3.3/bin/designer)
==18142== by 0x80ACFD8: (within /usr/lib/qt-3.3/bin/designer)
==18142== by 0x8088A77: (within /usr/lib/qt-3.3/bin/designer)
==18142== by 0x8086775: (within /usr/lib/qt-3.3/bin/designer)
==18142== by 0x1C3ABAD3: __libc_start_main (in /lib/tls/libc-2.3.3.so)
==18142==
==18142== LEAK SUMMARY:
==18142== definitely lost: 10016 bytes in 202 blocks.
==18142== possibly lost: 272 bytes in 3 blocks.
==18142== still reachable: 371859 bytes in 9392 blocks.
==18142== suppressed: 0 bytes in 0 blocks.
The mark-sweep checker reports:
[...]
==18124== 128+4014 bytes in 1 blocks are definitely lost in loss record 461 of 483
==18124== at 0x1B9043F3: operator new(unsigned) (vg_replace_malloc.c:132)
==18124== by 0x1D2CC02B: KThemeStylePlugin::keys() const (in /usr/lib/kde3/plugins/styles/kthemestyle.so)
==18124== by 0x1BECFDFD: QStylePluginPrivate::featureList() const (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18124== by 0x1BE869A0: QGPluginManager::addLibrary(QLibrary*) (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18124== by 0x1BE85FCB: QGPluginManager::featureList() const (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18124== by 0x1BECF3A3: QStyleFactory::keys() (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18124== by 0x80B7EA1: (within /usr/lib/qt-3.3/bin/designer)
==18124== by 0x8088B65: (within /usr/lib/qt-3.3/bin/designer)
==18124== by 0x8086775: (within /usr/lib/qt-3.3/bin/designer)
==18124== by 0x1C3ABAD3: __libc_start_main (in /lib/tls/libc-2.3.3.so)
==18124==
==18124== LEAK SUMMARY:
==18124== definitely lost: 15646 bytes in 243 blocks.
==18124== indirectly lost: 149304 bytes in 4977 blocks.
==18124== possibly lost: 14197 bytes in 33 blocks.
==18124== still reachable: 198076 bytes in 4291 blocks.
==18124== suppressed: 0 bytes in 0 blocks.
The summary is the interesting bit: it shows that the old algorithm
thinks there's only 10k of leakage, and that the heap has 371k of
reachable stuff. The mark-sweep algorithm thinks there's 15k of
unreferenced memory, which in turn references 149k of lost memory, and
the living heap is only 200k.
I included a loss record for comparison; the 128+4014 means that the
reported block is only 128 bytes, but it references a further 4014 bytes
of heap.
Here's an before and after example of the same leak:
Original:
==18212== 224 bytes in 7 blocks are definitely lost in loss record 330 of 443
==18212== at 0x1B9043F3: operator new(unsigned) (in /usr/lib/valgrind/vgpreload_memcheck.so)
==18212== by 0x1CB7BC7E: ???
==18212== by 0x1CB7CF3C: ???
==18212== by 0x1BE6D424: QComLibrary::createInstanceInternal() (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18212== by 0x1BE6DA07: QComLibrary::qtVersion() (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18212== by 0x1BE85F24: QGPluginManager::featureList() const (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18212== by 0x80A4CCD: (within /usr/lib/qt-3.3/bin/designer)
==18212== by 0x8088897: (within /usr/lib/qt-3.3/bin/designer)
==18212== by 0x8086775: (within /usr/lib/qt-3.3/bin/designer)
==18212== by 0x1C3ABAD3: __libc_start_main (in /lib/tls/libc-2.3.3.so)
Mark-sweep:
==18202== 256+5724 bytes in 8 blocks are definitely lost in loss record 300 of 480
==18202== at 0x1B9043F3: operator new(unsigned) (vg_replace_malloc.c:132)
==18202== by 0x1CB7BC7E: ???
==18202== by 0x1CB7CF3C: ???
==18202== by 0x1BE6D424: QComLibrary::createInstanceInternal() (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18202== by 0x1BE6DA07: QComLibrary::qtVersion() (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18202== by 0x1BE85F24: QGPluginManager::featureList() const (in /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.3)
==18202== by 0x80CE092: (within /usr/lib/qt-3.3/bin/designer)
==18202== by 0x80A4899: (within /usr/lib/qt-3.3/bin/designer)
==18202== by 0x8088897: (within /usr/lib/qt-3.3/bin/designer)
==18202== by 0x8086775: (within /usr/lib/qt-3.3/bin/designer)
Showing the leak is really losing ~750 bytes per occurrance rather than
the 32 bytes the first loss record suggests.
J
|