Archived

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

NoClue

Mem allocation and freeing

Recommended Posts

Hi! If I allocate let say 4Mb in the beginning of my program do I need to free it upon exit or does it get released automatically when the proccess dies? /Erik [edited by - NoClue on October 13, 2003 7:44:10 AM]

Share this post


Link to post
Share on other sites
It is in "good taste" to free mem that You allocated. But yes system will free it. Or other... system should free it




"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We Would
When Losers Say Its Over With You Know That It’s A Lie The Gods Made Heavy Metal And It’s Never Gonna Die"

THE GODS MADE HEAVY METAL/by
ManOwaR

Share this post


Link to post
Share on other sites
Never assume the system does anything for you. On systems such as Windows 2000 or later, it will free the memory when the process dies, but older windows versions don''t. So it''s a bad habit of not cleaning up. Eventually, memory leaks can kill a machine and force it to reboot.

So, allocating means you have to deallocate. And if you don''t want to miss out any allocated memory, use a memory tracer.

Toolmaker



-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
You can take my word for it that Windows 98 SE is very sloppy in cleaning up memory that programs leave behind.

Share this post


Link to post
Share on other sites
Well I personally don''t think it''s a big deal. Pre-2000 versions of Windows pretty much have to be regularly rebooted anyway, so it''s not like much harm will come of it. They should upgrade anyway.

Share this post


Link to post
Share on other sites
quote:
Original post by andy_fish
They should upgrade anyway.


If you do your part, they shouldn''t have to upgrade. It''s not that hard to free allocated memory, so just do it. It''s not like you have to write a thousand lines of code to free memory.

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

Share this post


Link to post
Share on other sites