[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)
Memmory Leak Tools
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++?
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
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
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.
quote:Original post by zipless
The best way i''ve found is to overload the new&delete or alloc and free functions.
Does that, in your estimation, surpass the CRT family of debug functions declared in <crtdbg.h>?
[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
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 ]
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
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
Kylotan:
http://www.gamedev.net/community/forums/topic.asp?topic_id=71992
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
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
zipless
Thanks Simon. There is a #define mentioned in MSDN which claims to insert the file/line information, but it simply doesn''t.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement