Skip to main content
GameDev.net gamedev.net
🔒 Locked

Finding Memory Leaks

Started by Facehat Apr 8, 2000 at 12:57 PM 9 replies 900+ views
Original Post
Facehat
Facehat
I''ve heard of some programs which can find memory leaks C++ code. Does anyone have any reccomendations about which one of these I should get? And what sort of price can I expect to pay? --TheGoop
SiCrane
SiCrane
Boehm''s Garbage collection library is avaliable from Xerox for free, and can perform leak detection as well as garbage collection. (Because, after all, every time you need to collect the garbage, you''ve got a leak. )
Facehat
Facehat
Sounds pretty good . But what part of the site is that on? (I used the search utility, but I was unable to find it)

--TheGoop
Qoy
Qoy
Yeah, I looked for the thing on www.xerox.com for it too, but couldn''t find it...
SiCrane
SiCrane
Here''s a Xerox ftp directory: ftp://parcftp.xerox.com/pub/gc/

But aparantly since the last time I checked, Boehm had moved from Xerox to SGI to HP. Here''s the HP link, I didn''t check if the library was actually more recent than the Xerox Parc link.

http://www.hpl.hp.com/personal/Hans_Boehm/gc/
Lord Chaos
Lord Chaos
If you run in debug mode, you can just use the _Crt functions to detect any over/undrwrite, memoryleaks and other useful information from the debug heap. Easy to use, for example run _CrtDumpMemoryLeaks() at the end of your program.

/ LC
Qoy
Qoy
I read in VC++ Developers Journal a while ago that _CrtDumpMemoryLeaks will give incorrect results if you include header files that declare objects, such as iostream.h (declared cout, cin, etc..). It said that it will return the size of those objects, because their destructors haven''t been run yet. It this true?
SiCrane
SiCrane
Of course that''s assuming you''re using Visual C++.
Staffan
Staffan
Qoy - I had those problems..So I would say it''s true. I logged it to the hd and got a 81k file with all the leaks in my application. Think I had any? Nah.

"Paranoia is the belief in a hidden order behind the visible." - Anonymous
KaneTHP
KaneTHP
One thing I''ve done to help track memory leaks was to override the new and delete operators to make them count the number of bytes allocated and deallocated. You may also want to look into creating your own memory manager that allocates memory in large blocks - this way you can help prevent fragmentation (or at least control w/ your own routines) and you simply deallocate all the blocks at the end. Just some ideas...
- Kane THP

"Feed the Children, Save the Whales, Free the Mallocs!"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.