On Fri, 25 Aug 2006, Zed Shaw wrote:

> And where are you getting your information that free doesn't free
> memory?  I'd like to read that since all my years of C coding says that
> is dead wrong.  Care to tell me how malloc/free would report 80M with
> Mutex but properly show the ram go down when there is no-Mutex?

a nice explanation:

"A couple of things: Some `malloc' implementations use mmap() to allocate
large blocks (sometimes the threshold is a page or two, sometimes more), so
this might be part of what you're seeing.  Some programs have allocation
patterns that interact badly with the way certain allocators work. Often, for
example, when some number of objects of a certain size have been allocated, a
future allocation cuts up a page into chunks of that size, gives you one, and
throws the rest onto a free list. If the allocation pattern of a program is to
allocate many chunks of a certain size, free them, and then allocate many
chunks of a somewhat larger size, the allocator can't satisfy the latter
requests (as bunches of somewhat-too-small chunks are on the free lists)
without grabbing more address space from the OS (via sbrk()).  This is not
necessarily a bad thing, even though it makes it look like the overall size of
the program is expanding; though the address space may have grown, the pages
containing the `somewhat-too-small' chunks that have been freed are eventually
swapped out; unless they're touched again their only downside is consumption
of swap space.  It's really only a problem for programs with _very_ large
footprints; even in cases like that, at some point most malloc implementations
will `unslice' space from previously sliced pages."

http://groups.google.com/group/comp.unix.programmer/browse_frm/thread/23e7be26dd21434a/2f84b3dc080c7519?lnk=gst&q=memory+not+really+freed&rnum=9#2f84b3dc080c7519

the paper referenced is also good.

ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps

regards.

-a
-- 
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dalai lama