[Qt-interest] How to debug memory leaks in QT based application?

Brad Hards bradh at frogmouth.net
Sun Apr 18 02:30:21 CEST 2010


On Friday 09 April 2010 11:48:40 pm Nicolas Rannou wrote:
> The problem is that as soon as we use something from QT in our
> application, Valgrind reports a lot of memory leaks inside QT (not
> related to our application)... So it is almost impossible to find the
> leaks I am interested in.
Qt, not QT, please.
 
> Do you know why Valgrind reports these leaks?
The problem (in my experience) is that the glib-based event loop just isn't 
clean. You didn't describe the errors, so I don't know if this the particular 
problem you are experiencing. An easy way to test is to run one of the Qt 
examples and observe the errors.

There are also some leaks in fontconfig. You may also see those depending on 
which bits of Qt you are using.

> Do you know how to debug memory leaks in a QT based application?
What I usually do is to build without the glib event loop, or to disable using 
it using QT_NO_GLIB=1 in the environment.

I don't know how to deal with the fontconfig issues without a suppression. If 
you need to borrow one, a google search of something like "fontconfig valgrind 
suppression" will give you some examples to borrow.

> Is Valgrind well suited for that or would you suggest to use something
> else?
I can't answer this. What suits you depends on your specific approaches and 
needs.

HTH

Brad



More information about the Qt-interest-old mailing list