Re: [gtk-list] Re: Unix Memory Management : Clearing up a few misconceptions (was Re: how can I trust glib when it has so manymemleaks?)



On Thu, Mar 18, 1999 at 01:06:36PM -0800, Michael Babcock wrote:
> > UNDER UNIX, WHEN YOU FREE() MEMORY, IT IS NOT RELEASED TO THE OS. THE
> > SIZE OF YOUR PROCESS WON'T EVER SHRINK, IT CAN ONLY INCREASE.
> 
> I just did some tests to confirm that I'm not going insane, and yes
> free() DOES return the memory. I tested X (open and close netscape),
> emacs (load and kill a large buffer) and a trivial program of my own
> that just calls malloc(), then free() a bit later. Even if X and Emacs
> was doing something weird, my test program wasn't.

>From info glibc-2.1 :

Freeing Memory Allocated with `malloc'
--------------------------------------     

 When you no longer need a block that you got with `malloc', use the
 function `free' to make the block available to be allocated again. 

 [...]

 Occasionally, `free' can actually return memory to the operating
 system and make the process smaller.  Usually, all it can do is allow a
 later call to `malloc' to reuse the space.  In the meantime, the space
 remains in your program as part of a free-list used internally by
 `malloc'.               


-- 
Undergraduate student of Computer Science 
PGP public key : finger celli@cs.unibo.it
http://caristudenti.cs.unibo.it/~celli



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]