November 24, 2010

Jonathan Jonathan
Lab Rat
50 posts

Advice on checking for memory leaks and dangling resources?

 

I’m looking for pointers on how I can check whether I’ve created memory leaks in my Qt programme, or left resources dangling.

In someways Qt is quite dangerous. It does a lot of garbage collection for you, but doesn’t provide a complete solution.

15 replies

November 24, 2010

Alexander Kuchumov Alexander Kuchumov
Lab Rat
377 posts

use valgrind or other similar tools.

November 24, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

Qt solves QObject childs, not more. For all other stuff, I propose the usage of smart pointers. And valgrind or other tools for testing….

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 24, 2010

blex blex
Lab Rat
191 posts

As far as I know the Valgrind is Linux-only. What is your OS?

 Signature 

————————————

Oleksiy Balabay

November 24, 2010

Jonathan Jonathan
Lab Rat
50 posts

Windows 7 ;o(

I guess in an ideal world such an important function would be part of the Qt SDK.

November 24, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

why should it be part of Qt? it should be part of the Compiler :-)

For windows (commercially) use Purify (but that’s expensive)…

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 24, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

and Purify is not really very useful, very slow and needs tonnes of memory :( we need a better tool for win

November 24, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

Purify might be slow, but it works and shows, where the problems are, and not only for memory leaks. And currently, I haven’t tested other memory profiler for windows. Do you have any suggestions, which tool to use instead saying, we need another?

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 24, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts
Gerolf Reinwardt wrote:
Do you have any suggestions, which tool to use instead saying, we need another?

nope i’m looking for some alternative too …

November 24, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

You can use Bounds Checker, which is not faster, but different :-)
You can spend really much money and use AppSite, which would be shooting on birds with a cannon
Some people state, AQTime could be used for that (I only used that for performance profiling up to now).
If you search the web, most people state, all memory profilers for windows are too slow or too expensive (like AppSite which has a different scope, and cost something like my house :-) )

I know no freeware checker like valgrind :-(

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 24, 2010

Alexander Kuchumov Alexander Kuchumov
Lab Rat
377 posts

Purify is commercial application:(

November 24, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

like most memory profilers for windows :-(
I didn’t find a good memory profiler for linux for free…

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 24, 2010

blex blex
Lab Rat
191 posts

Some years ago I have used this tool http://www.codeproject.com/KB/applications/visualleakdetector.aspx

I do not know about modern versions of Visual Studio support, but it is free and open source.

 Signature 

————————————

Oleksiy Balabay

November 24, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

Hi,

if I understood correctly, visualleakdetector is a replacement of the MSVS internal leak detection (CRT debug functions) which must be added programatically. It only works in debug mode. and it can be compiled for new MSVS versions by using the source code. could work but only in the same way as the MSVS build in detection with just a bit more information…

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 25, 2010

blex blex
Lab Rat
191 posts
Gerolf Reinwardt wrote:
could work but only in the same way as the MSVS build in detection with just a bit more information…

Sorry, I do not know it internals. When I use it then in the debug output on program exit I get the human readable list of leaks with information where leak is created. It was enough for me at that time.

 Signature 

————————————

Oleksiy Balabay

December 14, 2010

DeVeL-2010 DeVeL-2010
Lab Rat
24 posts

AQTime can detect memory leaks, but it’s mainly for profiling.
Intel Parallel Inspector (is also part of the Intel Parallel Studio) is another option.
Both are commerical, but you can always get a trial version.

 
  ‹‹ [SOLVED]Cannot execute my slot when menu item was clicked.      issue with QComboBox with Windows Vista ››

You must log in to post a reply. Not a member yet? Register here!