Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, October 2004
QT & Valgrind


Message 1 in thread

Hello,

I am trying to isolate possible memory leaks in a GUI application I am
working on.  I am using Valgrind (which I have used for non QT apps with
great success).  However, Valgrind reports memory leaks (under the
'definitely lost' category) for even the simplest QT applications (those
found in the examples/ folder).

Here is the Valgrind output for the aclock example:

/usr/share/doc/qt-devel-3.1.1/examples/aclock
> valgrind --leak-check=yes aclock
==21908== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
==21908== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
==21908== Using valgrind-20030725, a program supervision framework for
x86-linux.
==21908== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
==21908== Estimated CPU clock rate is 2777 MHz
==21908== For more details, rerun with: -v
==21908==
==21908== Syscall param write(buf) contains uninitialised or unaddressable
byte(s)
==21908==    at 0x40B456B8: __GI___libc_write (in /lib/libc-2.3.2.so)
==21908==    by 0x4090620E: _X11TransWrite (in /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x408E5E91: (within /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x408E74FC: _XReply (in /usr/X11R6/lib/libX11.so.6.2)
==21908==    Address 0x42CD3498 is 116 bytes inside a block of size 2048
alloc'd
==21908==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==21908==    by 0x408D7D8B: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x403D6BD2: qt_init_internal(int*, char**, _XDisplay*,
unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==21908==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)==21908==
==21908== Syscall param writev(vector[...]) contains uninitialised or
unaddressable byte(s)
==21908==    at 0x40181C24: vgAllRoadsLeadToRome_writev (vg_intercept.c:108)
==21908==    by 0x40181C60: __writev (vg_intercept.c:732)
==21908==    by 0x4090564F: (within /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x4090626E: _X11TransWritev (in
/usr/X11R6/lib/libX11.so.6.2)
==21908==    Address 0x42CD34A9 is 133 bytes inside a block of size 2048
alloc'd
==21908==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==21908==    by 0x408D7D8B: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x403D6BD2: qt_init_internal(int*, char**, _XDisplay*,
unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==21908==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)==21908==
==21908== Syscall param write(buf) contains uninitialised or unaddressable
byte(s)
==21908==    at 0x40B456B8: __GI___libc_write (in /lib/libc-2.3.2.so)
==21908==    by 0x4090620E: _X11TransWrite (in /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x408E5E91: (within /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x408E5D18: _XFlush (in /usr/X11R6/lib/libX11.so.6.2)
==21908==    Address 0x42CD34AC is 136 bytes inside a block of size 2048
alloc'd
==21908==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==21908==    by 0x408D7D8B: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x403D6BD2: qt_init_internal(int*, char**, _XDisplay*,
unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==21908==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)==21908==
==21908== Syscall param write(buf) contains uninitialised or unaddressable
byte(s)
==21908==    at 0x40B456B8: __GI___libc_write (in /lib/libc-2.3.2.so)
==21908==    by 0x40D4B6BE: _IceTransWrite (in /usr/X11R6/lib/libICE.so.6.3)
==21908==    by 0x40D42308: _IceWrite (in /usr/X11R6/lib/libICE.so.6.3)
==21908==    by 0x40D41F21: IceFlush (in /usr/X11R6/lib/libICE.so.6.3)
==21908==    Address 0x43C165A0 is 12 bytes inside a block of size 1024
alloc'd
==21908==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==21908==    by 0x40D3F43F: IceOpenConnection (in
/usr/X11R6/lib/libICE.so.6.3)
==21908==    by 0x40D3437A: SmcOpenConnection (in
/usr/X11R6/lib/libSM.so.6.0)
==21908==    by 0x403E06BB: QSessionManager::QSessionManager(QApplication*,
QString&, QString&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==21908== discard syms in /usr/lib/qt-3.1/plugins/styles/bluecurve.so due to
munmap()
==21908== discard syms in /usr/lib/gconv/ISO8859-1.so due to munmap()
==21908== discard syms in /lib/libnss_files-2.3.2.so due to munmap()
==21908==
==21908== ERROR SUMMARY: 11 errors from 4 contexts (suppressed: 14 from 1)
==21908== malloc/free: in use at exit: 245044 bytes in 3947 blocks.
==21908== malloc/free: 164356 allocs, 160409 frees, 73889756 bytes
allocated.
==21908== For counts of detected errors, rerun with: -v
==21908== searching for pointers to 3947 not-freed blocks.
==21908== checked 15230036 bytes.
==21908==
==21908==
==21908== 16 bytes in 1 blocks are definitely lost in loss record 25 of 108
==21908==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==21908==    by 0x408E99A2: (within /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x408EB82B: XrmGetStringDatabase (in
/usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x408CF4B7: (within /usr/X11R6/lib/libX11.so.6.2)
==21908==
==21908==
==21908== 24 bytes in 1 blocks are definitely lost in loss record 32 of 108
==21908==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==21908==    by 0x40CE887E: (within /usr/lib/libfreetype.so.6.3.2)
==21908==    by 0x40CE8C30: FT_Alloc (in /usr/lib/libfreetype.so.6.3.2)
==21908==    by 0x40D03CE2: (within /usr/lib/libfreetype.so.6.3.2)
==21908==
==21908==
==21908== 28 bytes in 1 blocks are definitely lost in loss record 38 of 108
==21908==    at 0x40029507: __builtin_new (vg_replace_malloc.c:172)
==21908==    by 0x4002955E: operator new(unsigned) (vg_replace_malloc.c:185)
==21908==    by 0x442250AB: ???
==21908==    by 0x44223745: ???
==21908==
==21908==
==21908== 216 bytes in 1 blocks are definitely lost in loss record 70 of 108
==21908==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==21908==    by 0x4396A8A2: _XimOpenIM (in
/usr/X11R6/lib/X11/locale/lib/common/ximcp.so.2)
==21908==    by 0x40932677: (within /usr/X11R6/lib/libX11.so.6.2)
==21908==    by 0x4396A1CE: _XimRegisterIMInstantiateCallback (in
/usr/X11R6/lib/X11/locale/lib/common/ximcp.so.2)
==21908==
==21908== LEAK SUMMARY:
==21908==    definitely lost: 284 bytes in 4 blocks.
==21908==    possibly lost:   0 bytes in 0 blocks.
==21908==    still reachable: 244560 bytes in 3942 blocks.
==21908==         suppressed: 200 bytes in 1 blocks.
==21908== Reachable blocks (those to which a pointer was found) are not
shown.
==21908== To see them, rerun with: --show-reachable=yes
==21908==

Here are my systems stats:
Red Hat Linux 9.0
gcc 3.2.2
QT 3.1.1


My first question is:  Is this normal behavior for Valgrind and QT
applications?  I've combed the archives and seen this question asked, but no
answer was given (at least nothing conclusive).  Are there any Valgrind
experts out there who can explain this?

As for my application, I notice that the systesm free memory is steadily
being eaten up over time (using the free command to report free/used
memory).  I'd like to use Valgrind to find what in my app is causing this,
but I am unsure of Valgrind when it produces memory leak output for apps
that I assume really dont have memory leaks!



TIA,
Thomas Wharton


Message 2 in thread

Hi,

> I am trying to isolate possible memory leaks in a GUI application I am
> working on.  I am using Valgrind (which I have used for non QT apps with
> great success).  However, Valgrind reports memory leaks (under the
> 'definitely lost' category) for even the simplest QT applications (those
> found in the examples/ folder).

Memory leaks have already been discussed on this list.

It does happen that Qt allocates memory that is never freed thereafter. 
However this happens once at initialization, the allocated memory is 
used throughout the program until the program stops, at which point 
memory is reclaimed by the system. This is to be considered as normal 
behavior and cannot be modified in Qt 3.

In short, memory leaks usually reported by Valgrind or other memory 
debuggers inside Qt are usually not memory leaks in the strict sense. 
They do produce "noise" though, which doesn't help understanding the 
output of memory debuggers. Maybe this will be fixed in upcoming 
versions of Qt.

In your case, it looks like most errors messages are actually related to 
X11 libraries, not Qt.

--
 [ signature omitted ] 

Message 3 in thread

Thanks Dimitri, for your input.  Before I posted I did read the posts
regarding Valgrind and memory leaks.  However, no previous post provided an
adequate solution to my particular problem.

Your explanation leads me to believe that I cannot trust the output of
Valgrind.  However, I still need to figure out the source of my systems
declining free memory while my app is running (therefore, it cant be one
time inits that are at fault).

As for the X11 libs, I cant imagine what to do about that except maybe try
to find a more recent build and install it.  But that seems like a red
herring, after all, if I cant trust Valgrind report on QT, why would I trust
its report on X11.

Btw, I've attached a text file containing the results of Valgrind applied to
the application I am working on.  I've combed through that output and noted
that the leaks Valgrind indicated in my app were calls to new,  These calls
dynamically created widgets whose parents where statically created.  Based
on QT documentation, I should not have to explicitly delete these widgets as
the parents will take care of deleting them (I'm assuming that's true).

Thanks,
Thom Wharton


-----Original Message-----
From: owner-qt-interest@xxxxxxxxxxxxx
[mailto:owner-qt-interest@xxxxxxxxxxxxx]On Behalf Of Dimitri
Sent: Monday, October 11, 2004 10:58 AM
To: Qt-Interest
Subject: Re: QT & Valgrind


Hi,

> I am trying to isolate possible memory leaks in a GUI application I am
> working on.  I am using Valgrind (which I have used for non QT apps with
> great success).  However, Valgrind reports memory leaks (under the
> 'definitely lost' category) for even the simplest QT applications (those
> found in the examples/ folder).

Memory leaks have already been discussed on this list.

It does happen that Qt allocates memory that is never freed thereafter.
However this happens once at initialization, the allocated memory is
used throughout the program until the program stops, at which point
memory is reclaimed by the system. This is to be considered as normal
behavior and cannot be modified in Qt 3.

In short, memory leaks usually reported by Valgrind or other memory
debuggers inside Qt are usually not memory leaks in the strict sense.
They do produce "noise" though, which doesn't help understanding the
output of memory debuggers. Maybe this will be fixed in upcoming
versions of Qt.

In your case, it looks like most errors messages are actually related to
X11 libraries, not Qt.

--
 [ signature omitted ] 
/home/wharton/projects/cal/g0020
> valgrind --leak-check=yes --num-callers=40 cal > foo.txt
==22035== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
==22035== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
==22035== Using valgrind-20030725, a program supervision framework for x86-linux.
==22035== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
==22035== Estimated CPU clock rate is 2770 MHz
==22035== For more details, rerun with: -v
==22035==
==22035== Syscall param write(buf) contains uninitialised or unaddressable byte(s)
==22035==    at 0x40B8B6B8: __GI___libc_write (in /lib/libc-2.3.2.so)
==22035==    by 0x4094D20E: _X11TransWrite (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4092CE91: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4092E4FC: _XReply (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4091B721: XInternAtom (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40937E4D: XSetWMProperties (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x404089F9: QWidget::create(unsigned long, bool, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404C2059: QWidget::QWidget(QWidget*, char const*, unsigned) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4056C803: QMainWindow::QMainWindow(QWidget*, char const*, unsigned) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x8067388: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:45)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==    Address 0x42FADA8C is 116 bytes inside a block of size 2048 alloc'd
==22035==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==22035==    by 0x4091ED8B: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x403D6BD2: qt_init_internal(int*, char**, _XDisplay*, unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4043242F: QApplication::construct(int&, char**, QApplication::Type) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404320FB: QApplication::QApplication(int&, char**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806A909: main (main.cpp:46)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035== Syscall param writev(vector[...]) contains uninitialised or unaddressable byte(s)
==22035==    at 0x40181C24: vgAllRoadsLeadToRome_writev (vg_intercept.c:108)
==22035==    by 0x40181C60: __writev (vg_intercept.c:732)
==22035==    by 0x4094C64F: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4094D26E: _X11TransWritev (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4092DD64: _XSend (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x409231D9: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4092391A: XPutImage (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4486A2E0: XcursorImageLoadCursor (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4486A7D7: XcursorImagesLoadCursor (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4486DB0F: XcursorTryShapeCursor (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4091066B: _XTryShapeCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40910A48: XCreateGlyphCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40910EB8: XCreateFontCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x403E7CA7: QCursor::update() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403E7817: QCursor::handle() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40407FB1: qt_x11_enforce_cursor(QWidget*, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40408805: QWidget::create(unsigned long, bool, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404C2059: QWidget::QWidget(QWidget*, char const*, unsigned) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4056C803: QMainWindow::QMainWindow(QWidget*, char const*, unsigned) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x8067388: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:45)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==    Address 0x42FADA99 is 129 bytes inside a block of size 2048 alloc'd
==22035==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==22035==    by 0x4091ED8B: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x403D6BD2: qt_init_internal(int*, char**, _XDisplay*, unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4043242F: QApplication::construct(int&, char**, QApplication::Type) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404320FB: QApplication::QApplication(int&, char**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806A909: main (main.cpp:46)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035== Syscall param write(buf) contains uninitialised or unaddressable byte(s)
==22035==    at 0x40B8B6B8: __GI___libc_write (in /lib/libc-2.3.2.so)
==22035==    by 0x4094D20E: _X11TransWrite (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4092CE91: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4092CD18: _XFlush (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x409135EB: XFlush (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4040A6BE: QWidget::setCursor(QCursor const&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404AED6E: QSizeGrip::QSizeGrip(QWidget*, char const*) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x405F8F6A: QDialog::setSizeGripEnabled(bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4060207B: QFileDialog::init() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)==22035==    by 0x40601887: QFileDialog::QFileDialog(QWidget*, char const*, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806749E: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:53)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==    Address 0x42FADB00 is 232 bytes inside a block of size 2048 alloc'd
==22035==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==22035==    by 0x4091ED8B: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x403D6BD2: qt_init_internal(int*, char**, _XDisplay*, unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4043242F: QApplication::construct(int&, char**, QApplication::Type) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404320FB: QApplication::QApplication(int&, char**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806A909: main (main.cpp:46)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035== Thread 2:
==22035== Conditional jump or move depends on uninitialised value(s)
==22035==    at 0x40DA04ED: thread_wrapper (vg_libpthread.c:648)
==22035==    by 0x4016FDD2: do__quit (vg_scheduler.c:2146)
==22035==
==22035== Thread 2:
==22035== Conditional jump or move depends on uninitialised value(s)
==22035==    at 0x40DA04FF: thread_wrapper (vg_libpthread.c:651)
==22035==    by 0x4016FDD2: do__quit (vg_scheduler.c:2146)
==22035==
==22035== Syscall param write(buf) contains uninitialised or unaddressable byte(s)
==22035==    at 0x40B8B6B8: __GI___libc_write (in /lib/libc-2.3.2.so)
==22035==    by 0x40D916BE: _IceTransWrite (in /usr/X11R6/lib/libICE.so.6.3)
==22035==    by 0x40D88308: _IceWrite (in /usr/X11R6/lib/libICE.so.6.3)
==22035==    by 0x40D87F21: IceFlush (in /usr/X11R6/lib/libICE.so.6.3)
==22035==    by 0x40D7ACB2: SmcSetProperties (in /usr/X11R6/lib/libSM.so.6.0)
==22035==    by 0x403DF212: (within /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403DF2AA: (within /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403DF617: (within /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403DF401: (within /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40D7C47C: _SmcProcessMessage (in /usr/X11R6/lib/libSM.so.6.0)
==22035==    by 0x40D88A50: IceProcessMessages (in /usr/X11R6/lib/libICE.so.6.3)
==22035==    by 0x403DFEA9: QSmSocketReceiver::socketActivated(int) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403E0181: QSmSocketReceiver::qt_invoke(int, QUObject*) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404940C8: QObject::activate_signal(QConnectionList*, QUObject*) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404941A4: QObject::activate_signal(int, int) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40774281: QSocketNotifier::activated(int) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404B04AF: QSocketNotifier::event(QEvent*) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40435F23: QApplication::internalNotify(QObject*, QEvent*) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40435B18: QApplication::notify(QObject*, QEvent*) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40410EF9: QEventLoop::activateSocketNotifiers() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403EE8D6: QEventLoop::processEvents(unsigned) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40449CF5: QEventLoop::enterLoop() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40449B97: QEventLoop::exec() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40436150: QApplication::exec() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806AACA: main (main.cpp:76)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==    Address 0x442F1B20 is 12 bytes inside a block of size 1024 alloc'd
==22035==    at 0x40029888: calloc (vg_replace_malloc.c:273)
==22035==    by 0x40D8543F: IceOpenConnection (in /usr/X11R6/lib/libICE.so.6.3)
==22035==    by 0x40D7A37A: SmcOpenConnection (in /usr/X11R6/lib/libSM.so.6.0)
==22035==    by 0x403E06BB: QSessionManager::QSessionManager(QApplication*, QString&, QString&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40432C04: QApplication::initialize(int, char**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4043245D: QApplication::construct(int&, char**, QApplication::Type) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404320FB: QApplication::QApplication(int&, char**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806A909: main (main.cpp:46)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035== discard syms in /usr/lib/qt-3.1/plugins/styles/bluecurve.so due to munmap()
==22035== discard syms in /usr/lib/gconv/ISO8859-1.so due to munmap()
==22035== discard syms in /lib/libnss_files-2.3.2.so due to munmap()
==22035==
==22035== ERROR SUMMARY: 144 errors from 6 contexts (suppressed: 14 from 1)
==22035== malloc/free: in use at exit: 336774 bytes in 4380 blocks.
==22035== malloc/free: 2697652 allocs, 2693272 frees, 134502894 bytes allocated.
==22035== For counts of detected errors, rerun with: -v
==22035== searching for pointers to 4380 not-freed blocks.
==22035== checked 16276848 bytes.
==22035==
==22035==
==22035== 16 bytes in 1 blocks are possibly lost in loss record 26 of 124
==22035==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==22035==    by 0x409309A2: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4093282B: XrmGetStringDatabase (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x409164B7: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x409165B7: XGetDefault (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x4486B21E: _XcursorGetDisplayInfo (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4486B2AE: XcursorSupportsARGB (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4486DA9E: XcursorTryShapeCursor (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4091066B: _XTryShapeCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40910A48: XCreateGlyphCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40910EB8: XCreateFontCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x403E7CA7: QCursor::update() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403E7817: QCursor::handle() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40407FB1: qt_x11_enforce_cursor(QWidget*, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40408805: QWidget::create(unsigned long, bool, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404C2059: QWidget::QWidget(QWidget*, char const*, unsigned) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4056C803: QMainWindow::QMainWindow(QWidget*, char const*, unsigned) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x8067388: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:45)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035==
==22035== 24 bytes in 1 blocks are definitely lost in loss record 33 of 124
==22035==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==22035==    by 0x40D2E87E: (within /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D2EC30: FT_Alloc (in /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D49CE2: (within /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D496B6: (within /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D49F80: (within /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D4A429: FT_Stream_OpenGzip (in /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D4BEE7: (within /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D3259C: (within /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D3292F: FT_Open_Face (in /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40D32669: FT_New_Face (in /usr/lib/libfreetype.so.6.3.2)
==22035==    by 0x40E28D6F: FcFreeTypeQuery (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x40E2874C: FcFileScan (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x40E28B13: FcDirScan (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x40E23926: FcConfigBuildFonts (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x40E2999B: FcInitLoadConfigAndFonts (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x40E299F4: FcInit (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x40D1C85A: XftInit (in /usr/X11R6/lib/libXft.so.2.1)
==22035==    by 0x40456410: QFont::initialize() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403D659C: qt_init_internal(int*, char**, _XDisplay*, unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4043242F: QApplication::construct(int&, char**, QApplication::Type) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404320FB: QApplication::QApplication(int&, char**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806A909: main (main.cpp:46)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035==
==22035== 32 bytes in 2 blocks are definitely lost in loss record 47 of 124
==22035==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==22035==    by 0x40E2D8D2: FcPatternCreate (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x40E2F228: FcPatternDuplicate (in /usr/lib/libfontconfig.so.1.0)
==22035==    by 0x4045544E: QFontPrivate::load(QFont::Script, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40454F80: QFontPrivate::loadUnicode(QFont::Script, QChar const&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4045507A: QFontPrivate::load(QFont::Script, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40456786: QFont::handle() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404C586D: QWidget::setFont(QFont const&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4053ECC5: QLabel::setFont(QFont const&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x408C95C7: QwtPlot::initPlot(QString const&) (qwt_plot.cpp:82)
==22035==    by 0x408C8E5D: QwtPlot::QwtPlot(QWidget*, char const*) (qwt_plot.cpp:43)
==22035==    by 0x8065BF6: MT11PlotView::createPlots() (mt11plotview.cpp:105)
==22035==    by 0x80659F3: MT11PlotView::MT11PlotView(MainWindow*, QWidget*, char const*,
int) (mt11plotview.cpp:76)
==22035==    by 0x806784E: MainWindow::createViews() (mainwindow.cpp:113)
==22035==    by 0x80674BF: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:57)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035==
==22035== 80 bytes in 2 blocks are definitely lost in loss record 58 of 124
==22035==    at 0x40029507: __builtin_new (vg_replace_malloc.c:172)
==22035==    by 0x4002955E: operator new(unsigned) (vg_replace_malloc.c:185)
==22035==    by 0x448DA0AB: ???
==22035==    by 0x448D8745: ???
==22035==    by 0x4073C2B4: QStylePluginPrivate::create(QString const&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4073B6EE: QStyleFactory::create(QString const&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40433DDE: QApplication::style() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404C3559: QWidget::style() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4056CA00: QMainWindow::QMainWindow(QWidget*, char const*, unsigned) (in
/usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x8067388: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:45)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035==
==22035== 168 bytes in 1 blocks are possibly lost in loss record 71 of 124
==22035==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==22035==    by 0x44869415: XcursorCursorsCreate (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4486A727: XcursorImagesLoadCursors (in /usr/X11R6/lib/libXcursor.so.1.0)==22035==    by 0x4486A7F6: XcursorImagesLoadCursor (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4486DB0F: XcursorTryShapeCursor (in /usr/X11R6/lib/libXcursor.so.1.0)
==22035==    by 0x4091066B: _XTryShapeCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40910A48: XCreateGlyphCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40910EB8: XCreateFontCursor (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x403E7CA7: QCursor::update() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403E7817: QCursor::handle() const (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40407FB1: qt_x11_enforce_cursor(QWidget*, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403D8CDE: QApplication::setOverrideCursor(QCursor const&, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40607848: QFileDialog::rereadDir() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4060194F: QFileDialog::QFileDialog(QWidget*, char const*, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806749E: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:53)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035==
==22035== 216 bytes in 1 blocks are definitely lost in loss record 77 of 124
==22035==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==22035==    by 0x43D018A2: _XimOpenIM (in /usr/X11R6/lib/X11/locale/lib/common/ximcp.so.2)
==22035==    by 0x40979677: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x43D011CE: _XimRegisterIMInstantiateCallback (in /usr/X11R6/lib/X11/locale/lib/common/ximcp.so.2)
==22035==    by 0x40979795: (within /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x40948B49: XRegisterIMInstantiateCallback (in /usr/X11R6/lib/libX11.so.6.2)
==22035==    by 0x403D55E9: qt_init_internal(int*, char**, _XDisplay*, unsigned long, unsigned long) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403D7B3D: qt_init(int*, char**, QApplication::Type) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4043242F: QApplication::construct(int&, char**, QApplication::Type) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404320FB: QApplication::QApplication(int&, char**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806A909: main (main.cpp:46)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035==
==22035== 676 bytes in 13 blocks are definitely lost in loss record 94 of 124
==22035==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==22035==    by 0x40D1A1F8: XftDrawCreateBitmap (in /usr/X11R6/lib/libXft.so.2.1)
==22035==    by 0x403F6615: QPixmap::convertFromImage(QImage const&, int) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404A6267: QPixmap::convertFromImage(QImage const&, QPixmap::ColorMode) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x4043C490: QBitmap::operator=(QImage const&) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x403F46C9: QPixmap::convertFromImage(QImage const&, int) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404A6267: QPixmap::convertFromImage(QImage const&, QPixmap::ColorMode) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404A53B3: QPixmap::QPixmap(char const**) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x405FABB0: (within /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40602C66: QFileDialog::init() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40601887: QFileDialog::QFileDialog(QWidget*, char const*, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806749E: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:53)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035==
==22035== 780 bytes in 15 blocks are definitely lost in loss record 97 of 124
==22035==    at 0x4002942A: malloc (vg_replace_malloc.c:153)
==22035==    by 0x40D1A138: XftDrawCreate (in /usr/X11R6/lib/libXft.so.2.1)
==22035==    by 0x403F23C3: QPixmap::init(int, int, int, bool, QPixmap::Optimization) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x404A4EF0: QPixmap::QPixmap(int, int, int, QPixmap::Optimization) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x405FAC1C: (within /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40602C66: QFileDialog::init() (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x40601887: QFileDialog::QFileDialog(QWidget*, char const*, bool) (in /usr/lib/qt-3.1/lib/libqt-mt.so.3.1.1)
==22035==    by 0x806749E: MainWindow::MainWindow(RMessageQueue*, QWidget*, char const*) (mainwindow.cpp:53)
==22035==    by 0x806A9BF: main (main.cpp:56)
==22035==    by 0x40ACB8C6: __libc_start_main (in /lib/libc-2.3.2.so)
==22035==    by 0x8051A10: (within /home/wharton/projects/cal/g0020/cal)
==22035==
==22035== LEAK SUMMARY:
==22035==    definitely lost: 1808 bytes in 34 blocks.
==22035==    possibly lost:   184 bytes in 2 blocks.
==22035==    still reachable: 334582 bytes in 4343 blocks.
==22035==         suppressed: 200 bytes in 1 blocks.
==22035== Reachable blocks (those to which a pointer was found) are not shown.
==22035== To see them, rerun with: --show-reachable=yes
==22035==
 
/home/wharton/projects/cal/g0020
>


Message 4 in thread

Hi,

> Your explanation leads me to believe that I cannot trust the output of
> Valgrind.  However, I still need to figure out the source of my systems
> declining free memory while my app is running (therefore, it cant be one
> time inits that are at fault).
> 
> As for the X11 libs, I cant imagine what to do about that except maybe try
> to find a more recent build and install it.  But that seems like a red
> herring, after all, if I cant trust Valgrind report on QT, why would I trust
> its report on X11.

I see no reason not to trust Valgrind. It's just that Valgrind and other 
memory debuggers report all memory allocations not followed by memory 
release as a memory leak. That's a memory leak in the loose sense. Some 
of these memory leaks are "by design" (this is often the case with 
once-only allocations inside Qt or X11) while other are real problems 
(repeated allocations by the same piece code without release for example).

Typically you'll want to look into repeated leaks reported by Valgrind.

> Btw, I've attached a text file containing the results of Valgrind applied to
> the application I am working on.  I've combed through that output and noted
> that the leaks Valgrind indicated in my app were calls to new,  These calls
> dynamically created widgets whose parents where statically created.  Based
> on QT documentation, I should not have to explicitly delete these widgets as
> the parents will take care of deleting them (I'm assuming that's true).

That's true. Note however that it'a bad idea to use static objects in 
C++, for a number of reasons that have already been discussed on this 
list. I'm not sure that's what you mean by "static" here, so please 
disregard this if you just mean:
	Class instance
as opposed to:
	Class* instance = new Class

Finally, note it's quite normal that "free" reports that a program eats 
more and more memory. Memory allocated by the C++ runtime is usually not 
released before the program exit.

--
 [ signature omitted ] 

Message 5 in thread

Dimitri wrote:
> Hi,
> 
>> ...
> That's true. Note however that it'a bad idea to use static objects in 
> C++, for a number of reasons that have already been discussed on this 
> list. I'm not sure that's what you mean by "static" here, so please 
> disregard this if you just mean:
>     Class instance

As I understood the OP he meant static as opposite of "dynamically 
allocating widgets", which I understand as using the operator 'new' 
(that is, allocated on the heap, technically speaking). "Static 
allocation" would hence be as mentioned above (that is, allocated on the 
stack). Roughly speaking...

> as opposed to:
>     Class* instance = new Class

Just for curiosity's sake: what's so "static" about the above call using 
'new'?

Cheers, Oliver


Message 6 in thread

Thanks again Dimitri, for your input on this.  You've given me something to
think about.

As for my use of the word 'static', I meant it as you said here (aka,
allocated on the stack):

>>	Class instance
>> as opposed to:
>>	Class* instance = new Class

Regards,
Thom Wharton


-----Original Message-----
From: owner-qt-interest@xxxxxxxxxxxxx
[mailto:owner-qt-interest@xxxxxxxxxxxxx]On Behalf Of Dimitri
Sent: Monday, October 11, 2004 12:00 PM
To: Qt-Interest
Subject: Re: QT & Valgrind


Hi,

> Your explanation leads me to believe that I cannot trust the output of
> Valgrind.  However, I still need to figure out the source of my systems
> declining free memory while my app is running (therefore, it cant be one
> time inits that are at fault).
>
> As for the X11 libs, I cant imagine what to do about that except maybe try
> to find a more recent build and install it.  But that seems like a red
> herring, after all, if I cant trust Valgrind report on QT, why would I
trust
> its report on X11.

I see no reason not to trust Valgrind. It's just that Valgrind and other
memory debuggers report all memory allocations not followed by memory
release as a memory leak. That's a memory leak in the loose sense. Some
of these memory leaks are "by design" (this is often the case with
once-only allocations inside Qt or X11) while other are real problems
(repeated allocations by the same piece code without release for example).

Typically you'll want to look into repeated leaks reported by Valgrind.

> Btw, I've attached a text file containing the results of Valgrind applied
to
> the application I am working on.  I've combed through that output and
noted
> that the leaks Valgrind indicated in my app were calls to new,  These
calls
> dynamically created widgets whose parents where statically created.  Based
> on QT documentation, I should not have to explicitly delete these widgets
as
> the parents will take care of deleting them (I'm assuming that's true).

That's true. Note however that it'a bad idea to use static objects in
C++, for a number of reasons that have already been discussed on this
list. I'm not sure that's what you mean by "static" here, so please
disregard this if you just mean:
	Class instance
as opposed to:
	Class* instance = new Class

Finally, note it's quite normal that "free" reports that a program eats
more and more memory. Memory allocated by the C++ runtime is usually not
released before the program exit.

--
 [ signature omitted ] 

Message 7 in thread

> Your explanation leads me to believe that I cannot trust the output of
> Valgrind.  However, I still need to figure out the source of my systems
> declining free memory while my app is running (therefore, it cant be one
> time inits that are at fault).

You can trust it, you just need to understand what is done and where. As you 
should have noticed, the "memory leaks" that you see will happen in each and 
every Qt application that you start under valgrind.

They should just be suppressed from the output by valgrind, or ignored by you. 
That's all there is to it. If you'll start seeing things that are related to 
your code, then you should worry.

> As for the X11 libs, I cant imagine what to do about that except maybe try
> to find a more recent build and install it.  But that seems like a red

Don't even bother. It's all OK.

Your version of valgrind simply doesn't suppress the "known leaks" from 
Qt/Xlib combination. You may want to create your

> herring, after all, if I cant trust Valgrind report on QT, why would I
> trust its report on X11.

You can trust the report on Qt. It's all right. The memory leaks that you see 
are by design. I.e. they are harmless. That's the memory that's allocated 
only once, treat them like you would static objects.

Cheers, Kuba Ober


Message 8 in thread

> Your version of valgrind simply doesn't suppress the "known leaks" from
> Qt/Xlib combination. You may want to create your
own suppression list file.
Hit "send" too quickly.

Cheers, Kuba Ober


Message 9 in thread

> > Your version of valgrind simply doesn't suppress the "known leaks" from
> > Qt/Xlib combination. You may want to create your
> own suppression list file.
> Hit "send" too quickly.
> 
> Cheers, Kuba Ober

It would be lovely if Trolltech could supply us with a Qt/X11 suppression
file!

Has anyone written a decent GUI for valgrind yet?

Andy


Message 10 in thread

Hi,

On Wednesday 13 October 2004 02:22, Andy Brice wrote:
> > > Your version of valgrind simply doesn't suppress the "known leaks" from
> > > Qt/Xlib combination. You may want to create your
> >
> > own suppression list file.
> > Hit "send" too quickly.
> >
> > Cheers, Kuba Ober
>
> It would be lovely if Trolltech could supply us with a Qt/X11 suppression
> file!

We cannot do that, the X11 team should give you a suppression file, since the 
static memleaks are in their code, not in ours.

> Has anyone written a decent GUI for valgrind yet?

Check out the valgrind support in KDevelop.

Harald