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



Guillaume Laurent wrote:
> 
> (Unix programmers with a clue can skip this one - or proofread it for
> mistakes :-)

I may not have a clue :-) but my statements were based on my experiences
not just on theory.

> 
> First of all, though a few people in this thread have already
> correctly stated that free() does not release mem to the OS, even more
> people still have this misconception that, when you free() malloc'ed
> memory, it is released to the OS. THIS IS FALSE, under most
> implementations. So, to state things once and for all (yeah right :-) :
> 
> 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.

According to "ps axm" the SIZE of the process does shrink. Dramatically.
Is ps not a valid way to determine the memory allocated to a process?

So maybe this isn't guaranteed by any standard, but its not like I have
some oddball system here: Debian 2.1 (glibc 2.0).

--
Michael Babcock
Jim Henson's Creature Shop - Los Angeles
mbabcock@la.creatureshop.henson.com



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