Re: Valgrind and Memory leak
Isn't this a double thread?
If not, are you sure the leak actually occurs? Qt doesn't cause any memory leaks on its own, Trolltech puts much effort to assure that. If you really have a leak, it might be caused by the platform itself.
Re: Valgrind and Memory leak
Any idea of platform leaks???
Re: Valgrind and Memory leak
Did you check that you actually have a leak?
Re: Valgrind and Memory leak
This is the Leak summary i am gettting when i run my application using valgrind:
definitely lost:5689b in 118 blocks
possibly lost:0 b in 0 blocks
still reachable:295030b in 927 blocks
supressed:0 byts in 0 blocks
Can suggest wer actually leak is there..some lines from valgrind log
---QDialog::done(int)
QDialog::accept()
QMyDialog::closeEvent(QCloseEvent *)
QWidget::event(QEvent *)
Re: Valgrind and Memory leak
Did you use --leak-check=full --leak-resolution=high and --show-reachable=yes Valgrind options?
Re: Valgrind and Memory leak
These are the options i have used:
valgrind -v --show-reachable=no --leak-check=full --run-libc-freeres=yes
When i commented the setWindowIcon() there is decrease in definitely lost row.
Re: Valgrind and Memory leak
So please use the options I gave you. You'll get information about each potential leak. Then you'll be able to see if the leak comes from Qt or not.
Re: Valgrind and Memory leak
This some sample output from Valgrind:
Invalid read of size 4
at 0x4010DD3: (within /lib/ld-2.3.6.so)
by 0x4005F5B: (within /lib/ld-2.3.6.so)
by 0x4006431: (within /lib/ld-2.3.6.so)
by 0x4006A51: (within /lib/ld-2.3.6.so)
by 0x400A1F6: (within /lib/ld-2.3.6.so)
by 0x400B44E: (within /lib/ld-2.3.6.so)
by 0x400A3CA: (within /lib/ld-2.3.6.so)
by 0x43593D4: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== Address 0x43F1ED8 is 32 bytes inside a block of size 34 alloc'd
==5025== at 0x401D4B0: malloc (vg_replace_malloc.c:149)
==5025== by 0x4005DA5: (within /lib/ld-2.3.6.so)
==5025== by 0x4005EE5: (within /lib/ld-2.3.6.so)
==5025== by 0x4006431: (within /lib/ld-2.3.6.so)
==5025== by 0x43593D4: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x4358DDE: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025==
==5025== at 0x401D4B0: malloc (vg_replace_malloc.c:149)
==5025== by 0x400B540: (within /lib/ld-2.3.6.so)
==5025== by 0x4006DAF: (within /lib/ld-2.3.6.so)
==5025== by 0x400A1F6: (within /lib/ld-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x400A3CA: (within /lib/ld-2.3.6.so)
==5025== by 0x43593D4: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x4358DDE: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025==
==5025== Conditional jump or move depends on uninitialised value(s)
==5025== at 0x4010E21: (within /lib/ld-2.3.6.so)
==5025== by 0x4359072: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x412ED20: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x85DD0A6: QLibraryPrivate::load_sys() (in /home/SourceCode/myFile)
==5025== by 0x85D83D3: QLibraryPrivate::load() (in /home/SourceCode/myFile)
==5025== by 0x85D86B0: QLibraryPrivate::loadPlugin() (in /home/SourceCode/myFile)
==5025== by 0x85D4719: QFactoryLoader::instance(QString const&) const (in /home/SourceCode/myFile)
==5025== by 0x80EF9A0: createReadHandler(QIODevice*, QByteArray const&) (in /home/SourceCode/myFile)
==5025== by 0x80F0F29: QImageReaderPrivate::initHandler() (in /home/SourceCode/myFile)
==5025==
==5025== Conditional jump or move depends on uninitialised value(s)
==5025== at 0x4010E2C: (within /lib/ld-2.3.6.so)
==5025== by 0x4359072: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x412ED20: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x85DD0A6: QLibraryPrivate::load_sys() (in /home/SourceCode/myFile)
==5025== by 0x85D83D3: QLibraryPrivate::load() (in /home/SourceCode/myFile)
==5025== by 0x85D86B0: QLibraryPrivate::loadPlugin() (in /home/SourceCode/myFile)
==5025== by 0x85D4719: QFactoryLoader::instance(QString const&) const (in /home/SourceCode/myFile)
==5025== by 0x80EF9A0: createReadHandler(QIODevice*, QByteArray const&) (in /home/SourceCode/myFile)
==5025== by 0x80F0F29: QImageReaderPrivate::initHandler() (in /home/SourceCode/myFile)
==5025==
==5025== Conditional jump or move depends on uninitialised value(s)
==5025== at 0x4010D14: (within /lib/ld-2.3.6.so)
==5025== by 0x4006704: (within /lib/ld-2.3.6.so)
==5025== by 0x435936F: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x4358DDE: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x412ED20: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x85DD0A6: QLibraryPrivate::load_sys() (in /home/SourceCode/myFile)
==5025== by 0x85D83D3: QLibraryPrivate::load() (in /home/SourceCode/myFile)
==5025== by 0x85D86B0: QLibraryPrivate::loadPlugin() (in /home/SourceCode/myFile)
==5025==
==5025== Conditional jump or move depends on uninitialised value(s)
==5025== at 0x4010E2C: (within /lib/ld-2.3.6.so)
==5025== by 0x4006704: (within /lib/ld-2.3.6.so)
==5025== by 0x435936F: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x4358DDE: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x412ED20: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x85DD0A6: QLibraryPrivate::load_sys() (in /home/SourceCode/myFile)
==5025== by 0x85D83D3: QLibraryPrivate::load() (in /home/SourceCode/myFile)
==5025== by 0x85D86B0: QLibraryPrivate::loadPlugin() (in /home/SourceCode/myFile)
==5025==
==5025== Conditional jump or move depends on uninitialised value(s)
==5025== at 0x4010E2C: (within /lib/ld-2.3.6.so)
==5025== by 0x4004B78: (within /lib/ld-2.3.6.so)
==5025== by 0x4006792: (within /lib/ld-2.3.6.so)
==5025== by 0x435936F: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x4358DDE: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x412ED20: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x85DD0A6: QLibraryPrivate::load_sys() (in /home/SourceCode/myFile)
==5025== by 0x85D83D3: QLibraryPrivate::load() (in /home/SourceCode/myFile)
==5025==
==5025== Invalid read of size 4
==5025== at 0x4010E00: (within /lib/ld-2.3.6.so)
==5025== by 0x4004B78: (within /lib/ld-2.3.6.so)
==5025== by 0x4006792: (within /lib/ld-2.3.6.so)
==5025== by 0x400A1F6: (within /lib/ld-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x400A3CA: (within /lib/ld-2.3.6.so)
==5025== by 0x43593D4: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x4358DDE: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== Address 0x4473950 is 24 bytes inside a block of size 25 alloc'd
==5025== at 0x401D4B0: malloc (vg_replace_malloc.c:149)
==5025== by 0x4006B83: (within /lib/ld-2.3.6.so)
==5025== by 0x400A1F6: (within /lib/ld-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x400A3CA: (within /lib/ld-2.3.6.so)
==5025== by 0x43593D4: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x4358DDE: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==5025== by 0x412ED8D: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x400B44E: (within /lib/ld-2.3.6.so)
==5025== by 0x412F42C: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025== by 0x412ED20: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==5025==
==5025== Syscall param write(buf) points to uninitialised byte(s)
==5025== at 0x4000792: (within /lib/ld-2.3.6.so)
==5025== by 0x407229E: _X11TransWrite (in /usr/lib/libX11.so.6.2.0)
==5025== by 0x4077BD5: (within /usr/lib/libX11.so.6.2.0)
==5025== by 0x4077CAA: _XReply (in /usr/lib/libX11.so.6.2.0)
==5025== by 0x405DF70: XInternAtom (in /usr/lib/libX11.so.6.2.0)
==5025== by 0x4071DCA: XSetWMProperties (in /usr/lib/libX11.so.6.2.0)
==5025== by 0x80D4DB6: QWidgetPrivate::create_sys(unsigned long, bool, bool) (in /home/SourceCode/myFile)
==5025== by 0x80ABF2E: QWidget::create(unsigned long, bool, bool) (in /home/SourceCode/myFile)
==5025== by 0x80ACEC9: QWidgetPrivate::createWinId(unsigned long) (in /home/SourceCode/myFile)
==5025== by 0x80ACFC2: QWidgetPrivate::setWindowTitle_helper(QString const&) (in /home/SourceCode/myFile)
==5025== by 0x80AD2F6: QWidget::setWindowTitle(QString const&) (in /home/SourceCode/myFile)
==5025== by 0x8069955: myClass::myClass() (in /home/SourceCode/myFile)
==5025== Address 0x446B9F8 is 192 bytes inside a block of size 16,384 alloc'd
==5025== at 0x401C7EF: calloc (vg_replace_malloc.c:279)
==5025== by 0x4062CBD: XOpenDisplay (in /usr/lib/libX11.so.6.2.0)
==5025== by 0x80C00E3: qt_init(QApplicationPrivate*, int, _XDisplay*, unsigned long, unsigned long) (in /home/SourceCode/myFile)
==5025== by 0x807CCF8: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (in /home/SourceCode/myFile)
==5025== by 0x807DABD: QApplication::QApplication(int&, char**, int) (in /home/SourceCode/myFile)
==5025== by 0x806EC19: main (in /home/SourceCode/myFile)
==5025== LEAK SUMMARY:
==5025== definitely lost: 5,689 bytes in 118 blocks.
==5025== possibly lost: 0 bytes in 0 blocks.
==5025== still reachable: 295,030 bytes in 927 blocks.
==5025== suppressed: 0 bytes in 0 blocks.
i hav tried the option posted by you.This is the result shown by valgrind
Re: Valgrind and Memory leak
I don't see any leak reports here. Did you compile with debug information (like -g option to g++)? A leak report should be something like the following:
Quote:
==9626== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
==9626== at 0x401F91C: operator new[](unsigned) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==9626== by 0x8048460: main (t.cpp:5)
Anyway you can see in your report that most of the notes are caused by libc, libdl and your code.
Re: Valgrind and Memory leak
==5025== LEAK SUMMARY:
==5025== definitely lost: 5,689 bytes in 118 blocks.
==5025== possibly lost: 0 bytes in 0 blocks.
==5025== still reachable: 295,030 bytes in 927 blocks.
==5025== suppressed: 0 bytes in 0 blocks.
Then wat this leak summary says...Does it mean leak is there...I hav not tried debug option.Any idea??
Re: Valgrind and Memory leak
Try compiling with debug information so that valgrind can trace function calls. Anyway I don't think there is a leak in Qt (based on this report you pasted). I suggest you correct the things pointed out in your code though.
Re: Valgrind and Memory leak
I hav to try with debug..If the leak is not from Qt it should be from my appliction..The leak summary gives some leakage..