[Spread-users] Memory leak? FD leak? Other?
David Shaw
dshaw at archivas.com
Fri Aug 20 17:59:01 EDT 2004
On Fri, Aug 20, 2004 at 05:43:55PM -0400, John Schultz wrote:
> David Shaw wrote:
> >
> >This isn't true for all platforms. With glibc (i.e. virtually all
> >Linux systems), if you free a memory block, glibc may shrink your
> >heap, giving memory back to the OS. The OpenBSD libc does the same.
> >It all depends on a number of factors and platform-specific things,
> >and fragmentation can make this difficult, but glibc neatly hides all
> >this from the application. Some memory allocators even do things like
> >mmap-ing /dev/zero and thus make it dead easy to release memory back
> >to the system.
> >
> Generic memory managers can try to release pages, but memory
> fragmentation usually makes this *very* difficult except when large
> block allocations are released.
Absolutely, but again:
> >My point is that in general, it's not a good idea to try and outsmart
> >the OS here. When you want memory, malloc() it. When you are done
> >with it, free() it. Let the memory allocator do its job.
It's hard, and complex, and can't always be done. That doesn't mean
it should not be done. Especially for a long-running daemon process
like spread, it's important to free memory to at leave give the system
a fair shot at reclaiming it.
David
More information about the Spread-users
mailing list