Jump to content
  • Advertisement

Archived

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

Prozak

Memmory Leak Tools

This topic is 5928 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

What tools can I use to know if my application/ game is leaking memmory? In DOS, I would just do a "mem", run the program then do another "mem". If there was any diference, then I would know that there was a memory leak somewhere. How do I track this problem down in VC++?

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Advertisement

Check out the "_CrtCheckMemory" family of functions. There is sample code, etc.. on MSDN.

-z

Share this post


Link to post
Share on other sites
The best way i''ve found is to overload the new&delete or alloc and free functions.

Something like this:

#define malloc(size) (mymalloc(size.__FILE__,__LINE__))

then for every alloc put the details into a linked list,
when you free search the list and remove the related memory.

Now at the end of your programm after everything has been released write the contents of the list to a text file, open it and you not only see how much memory you have unreleased but also in what file at what line it was declared.

Checkout flipcode, i think they have a pretty decent tutorial on how to do it, check the articles here on gamedev.net as well.

zipless

Share this post


Link to post
Share on other sites
The best tool you can find is Numega Bounds Checker, but its expensive (it''s only downside to me is the price), then there is memprof in the Linux world, dont know if someone has already ported that to Windows.

Share this post


Link to post
Share on other sites
I seem to remember being able to get the MS CRT functions to tell me when I had memory leaks, but not how I''d allocated those leaks. Therefore I couldn''t find how to fix it. I looked through the docs but didn''t have any luck. Any clues on how to use these functions more effectively?

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]

Share this post


Link to post
Share on other sites
Alternatively you can use a package such as nuMega BoundsChecker which will do extensive leak detection, even on things like GDI resource handles etc.


Kylotan:

http://www.gamedev.net/community/forums/topic.asp?topic_id=71992






--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
I''ve never used crtdbg so i wouldn''t know. I like my overload functions, i can see exactly how much memory i''m using at any time and it has the nice leak detection thing as well.

zipless

Share this post


Link to post
Share on other sites
Thanks Simon. There is a #define mentioned in MSDN which claims to insert the file/line information, but it simply doesn''t.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!