Archived

This topic is now archived and is closed to further replies.

Check for stray resources after program termination

This topic is 6613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
In VC6, there is a way to have it print out a listing of all memory that you didn't free, but it won't tell you which variable it is. It will tell you the address, size and contents for each block though.
Somewhere in your program (I usually put it right before the program exits), add the line:

_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);

When you run the program (in debug mode), a report will be printed out in the debug window after the program finishes executing.
include file is

Note: I have no idea if this works in other compilers, or environments other than windows 95/98/nt.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
html got the include, should be crtdbg.h

Share this post


Link to post
Share on other sites
Say a program uses many bitmap handles and malloc'd data, and doesnt release them all, is there a program to check for handles/data still in memory, or does the program release all handles and malloc'd data automatically?

Share this post


Link to post
Share on other sites
There are also commercial tools that do this sort of thing.

One of the best is called BoundsChecker... it's pricey, but for serious development, it's well worth the cash. Catches virtually all types of memory leaks, resource leaks, etc.

Mason McCuskey
Spin Studios
www.spin-studios.com

Share this post


Link to post
Share on other sites