Mem allocation and freeing

Started by
6 comments, last by NoClue 20 years, 6 months ago
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]
Advertisement
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
"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We WouldWhen 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
Ok. Thanks!
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.

In other words, wipe your own ass.
You can take my word for it that Windows 98 SE is very sloppy in cleaning up memory that programs leave behind.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
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.
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!"

This topic is closed to new replies.

Advertisement