[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: better malloc strategies?

--On Monday, September 04, 2006 3:40 PM +0200 Hallvard B Furuseth <h.b.furuseth@usit.uio.no> wrote:

Some loose thoughts - don't remember which I've mentioned before:

Have you looked at the Hoard <http://www.hoard.org> and ptmalloc
<http://www.malloc.de/en/> allocators?  Ganesan R mentioned those in
openldap-devel thread "Thread-local malloc discussion summary", Apr
2003, but there were no replies:

Are there still loops that build arrays of values by reallocing one
more element (usually a pointer) in the array for each iteration?
Change things using pointer-to-array-of-values to use a struct
{ pointer to array, #allocated items, #used items }.

In some cases, I imagine you could use variable-length arrays if the
compiler supports them.  (Outside of any loops in function bodies, since
I've seen mention of implementations that use alloca() for them.  That
does not free the memory until the function returns.)  Use macro which
declare an array where available (C99, gcc, whatever), or malloc/free it

If you look at the mail from 8/30, you'll note that Howard finds libhoard to be the best allocator out of glibc, libumem, and hoard. I've actually switched all of my production LDAP servers to use hoard as the default allocator now.

I've not tried ptmalloc.


Quanah Gibson-Mount
Principal Software Developer
ITS/Shared Application Services
Stanford University
GnuPG Public Key: http://www.stanford.edu/~quanah/pgp.html