linello
linello

Reputation: 8694

Suppression files for Qt memory leaks with Valgrind

I usually write my classes in C++ and check if they leak memory using valgrind on Linux platform. I'm not satisfied until all the heap memory is freed.

Starting to write in Qt, I found how many leaks valgrind detects, also on a simple project. They are so many that it's difficult to detect my same leaks.

I read somewhere that is possibile to use a suppression files for valgrind which helps filtering out the unwanted leaks, but I can't find it.

I'm using Ubuntu 11.04 x64, g++ 4.5, Qt 4.7. Does somebody know how to cope with this problem?

Upvotes: 10

Views: 7849

Answers (3)

UmNyobe
UmNyobe

Reputation: 22890

Did you look at this "Valgrind Suppression File Howto" wiki?

Just for the record there are some underlying libraries in Qt (especially the ones in the painting process) which always leak small amount of memory. These are the one you need to suppress.

As you said, you should first create a minimal project, run it to create a valgrind suppression file and then apply that suppression file to your project.

Upvotes: 6

Shengwei Zhang
Shengwei Zhang

Reputation: 89

I Just using suppression file to suppress all the memory reported from Qt library like this:

    {
        <QtCore>
        Memcheck:Leak
        ...
        obj:/usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.6
    }

...

Upvotes: -1

Bruno Soares
Bruno Soares

Reputation: 796

Just pay attention that a lot of libraries have internal allocation structures that you'll never reach to clean up, and it's normal.

Upvotes: 0

Related Questions