Archived

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

Fighting memory leaks......

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

Hello everybody I wonder what is the best way to fight memory leaks....?? I guess using programs like Purify, or BoundsChecker, right????? The problem is that these 2 programs are very expensive, and it is allmost impossible to get a cracked version, only to test and evaluate them... So does anyone have or know where to get a crack or demo version of these programs??? What about other similar tools, or solutions ??? Any suggestions?? Thanx in advance -- Uros Life lived unexplored is life not worth living !

Share this post


Link to post
Share on other sites
You can very easily combat memory leaks by overloading the new and delete operators so that they log all allocations and deallocations. There is an article on flip code about this.

Z.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by JaZsT
Hello everybody

I wonder what is the best way to fight memory leaks....?? I guess using programs like Purify, or BoundsChecker, right????? The problem is that these 2 programs are very expensive, and it is allmost impossible to get a cracked version, only to test and evaluate them... So does anyone have or know where to get a crack or demo version of these programs??? What about other similar tools, or solutions ??? Any suggestions??




Call up the developer''s sales line. If they think you have a chance of buying their product, they will most likely send you an evaluation copy.

You are unlikely to get anyone sending you a warez copy on a software development forum. We''re interested in developing and selling software, not ripping off software companies.


Share this post


Link to post
Share on other sites
In MSVC you have a nonstandard function called "_msize" which is extremely useful. Like he said, overload new and delete, then keep an internal ''bytes used'' counter. Everytime new or delete is used, update the counter, then log: the size of the data requested (sizeof(T), it makes it easier to find out what''s causing the leak once you find one), the actual data usage (from _msize), and the counter. I ran my engine through a test much like this yesterday, and am pleased that I have no memory leaks .

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
I noticed in Code on the cob, Chris (er ... Mr.Hargrove?), made a huge pool of memory and tossed out chunks of the pool to anything hungry for memory. There was no ''free'' function, so you don''t have to worry about memory leaks, fragmentation.

"And with 1-2GB of Windows virtual memory, that''s way more than i''ll ever need." - Bill Gates

Share this post


Link to post
Share on other sites
To elaborate on what KingPin said above. If using MSVC goto

http://www.flipcode.com/totd

and search the page for "leaks".
to find the article "Detecting Memory Leaks, by Douglas Cox"

This method works great. You can get a list of filenames and line numbers where the leaks occur. Though it does involve a little editing of source code (some find+replace), its worth it.

Share this post


Link to post
Share on other sites
quote:
Original post by KingPin
"And with 1-2GB of Windows virtual memory, that''s way more than i''ll ever need." - Bill Gates


Heh ... you can bump it up to 3 with a command line swtch. Fortunately, the 64 bit version of Windows gives you 7152 Gigs for each user-mode process

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Martee
Fortunately, the 64 bit version of Windows gives you 7152 Gigs for each user-mode process



Why 7152 gigabytes? Sounds like an awfully low and arbitrary limit to me...

Share this post


Link to post
Share on other sites
I always recommend Paul Nettle''s mmgr library (well, its a source file and 2 headers) that overrides new, delete, new[], delete, malloc, free, the whole lot.

You''ll find it in the Ask Midnight column archives. For an example of usage, you can always see Portalib3D debug build

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
Community Service Announcement: Read How to ask questions the smart way before posting!

Share this post


Link to post
Share on other sites