So I've been trying to use QT4.4 in a project of mine, because its really easy to use QThread and QThreadStorage across various platforms (awesome work guys!). Now my problem is that I've been using valgrind to make sure my application doesn't leak any memory and also doesn't have any bad memory accesses.
Here is a very simple example of my usage:
#include <QApplication>
#include <QPushButton>
#include <QThread>
#include <iostream>
using namespace std;
class Thread : public QThread
{
public:
Thread();
virtual ~Thread();
void run();
};
Thread::Thread()
{
}
Thread::~Thread()
{
}
void Thread::run()
{
cout << "here I am\n";
}
int main(int argc, char *argv[])
{
Thread t;
t.start();
t.wait();
return 0;
}
I Then build this by doing "qmake -project", "qmake", "make", and then I run my freshly created executable and the output is:
> ./test
here I am
All nice and dandy so far, now I run valgrind the following way "valgrind --leak-check=full ./test" and what i see is that it complains a bit about some code in QT itself:
==14654== 152 bytes in 1 blocks are possibly lost in loss record 7 of 12
==14654== at 0x4021BDE: calloc (vg_replace_malloc.c:397)
==14654== by 0x4010627: (within /lib/ld-2.7.so)
==14654== by 0x40106EB: _dl_allocate_tls (in /lib/ld-2.7.so)
==14654== by 0x4BA4C3C: pthread_create@@GLIBC_2.1 (in /lib/tls/i686/cmov/libpthread-2.7.so)
==14654== by 0x49BA8DD: QThread::start(QThread:

riority) (in /usr/lib/libQtCore.so.4.4.0)
==14654== by 0x8048CAA: main (in /home/neo/downloads/test/test)
==14654== 744 bytes in 3 blocks are possibly lost in loss record 9 of 12
==14654== at 0x4021A92: memalign (vg_replace_malloc.c:460)
==14654== by 0x4021B3F: posix_memalign (vg_replace_malloc.c:569)
==14654== by 0x4EEC103: (within /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x4EED330: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x4EAA50E: g_array_sized_new (in /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x4EAA616: g_array_new (in /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x4EF839F: g_static_private_set (in /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x4EB9D3F: g_get_filename_charsets (in /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x4EB9DB0: (within /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x4EF8659: g_thread_init_glib (in /usr/lib/libglib-2.0.so.0.1600.3)
==14654== by 0x50F2636: g_thread_init (in /usr/lib/libgthread-2.0.so.0.1600.3)
==14654== by 0x4AD1800: QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(_GMainContext*) (in /usr/lib/libQtCore.so.4.4.0)
Now this is possible memory loss, I'm wondering that there could be two situations here either Valgrind is giving me a fall positive and if so I'd like to know if you guys have any handy supressions to add to the valgrind supression file that would filter out these cases ? The second possibility is that this is in fact a memory leak and I would hope to eliminate it as in my project i would start /stop threads quite frequently and if I lost 152 bytes each time this would add up quite fast.
Thanks for your time,
Rodney.