Unix Programming - Re: what happen to heap on programme exit

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > December 2005 > Re: what happen to heap on programme exit





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: what happen to heap on programme exit
Pascal Bourguignon

2005-12-19, 7:49 am

"apple.davinci" <apple.davinci@gmail.com> writes:
> I just to know the reason why . not care how much


You're not seeing what you believe you're seeing.

Here is the output of the free(1) command on linux:

total used free shared buffers cached
Mem: 1031584 997728 33856 0 60400 612364
-/+ buffers/cache: 324964 706620
Swap: 1004020 120532 883488

The memory that is actually 'free' as you understand it, is the
used + "free" - cached of the first line:
997728 + 33856 - 612364 = 419220

When you launch your program, if there is not enough "free" memory,
some of the memory used as disk cache is used. When your program
quits, all the memory it used is returned to the "free" memory, soon
to be used again as cache or for other programs. The columns named
"free" in the output of the command free(1) should be named "unused",
or "wasted".


So after your program exits, there is more memory _wasted_, not "free",
than before. Hopefully, soon enough the system will put it to good
use, either for other programs or as disk cache.


--
__Pascal Bourguignon__ http://www.informatimago.com/
Cats meow out of angst
"Thumbs! If only we had thumbs!
We could break so much!"
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com