[Merkaartor] Detecting memory leaks

Dirk Stöcker openstreetmap at dstoecker.de
Wed Jan 14 10:41:58 GMT 2009


On Tue, 13 Jan 2009, Richard Brinkman wrote:

> Recently I decided to play a bit with the valgrind tool to find memory 
> leaks in Merkaartor. Indeed I found and corrected some obvious leaks. 
> However valgrind finds a lot more errors that cannot be blamed on 
> Merkaartor but seems to be Qt errors. Does someone know if this is 
> normal or that Qt is terribly buggy. When Googling for an answer someone 
> suggested that Qt has it's own memory management and does not delete 
> memory but recycles it. This might be true for the errors "memory still 
> in use when the program exits", but not the other errors.

All X applications have such issues, as X does font-caching and a lot of 
other stuff, which is not freed until the program ends. This makes it 
complicated to spot all own problems and sometimes causes overlooking of 
unfreed memory. I did not find a solution for this problem till today

At least everything where valgrind says it is definitely lost should be 
fixed.

Regarding Qt memory mangement. Qt keeps track of all allocations which are 
somehow linked to its classes, so all subclasses, windows, widgets and so 
on are automatically freed when the base class is freed.

> Is there a better way to hunt for memory leaks of Qt applications other 
> than using valgrind? Other (free) memory checkers perhaps?

Valgrind is the best tools I know about.

Ciao
-- 
http://www.dstoecker.eu/ (PGP key available)




More information about the Merkaartor mailing list