[Gllug] mallinfo

Nix nix at esperi.org.uk
Fri Nov 2 12:41:50 UTC 2007


On 31 Oct 2007, t. clarke told this:
> My testing last night reveals that the malloc in use on my linux machine
> creates an 'arena' of a whopping 135,168 bytes on the very first request;

Actually this is probably overhead caused by malloc bookkeeping and its
attempt on first call to determine the end of the memory
arena. Subsequent arena expansions should be smaller (but always in
page-sized chunks).

> and since all subsequent requests were being satisfied within that huge
> block of memory, the returned value was always zero :-(

It would be useful if you said what version of glibc is in use.

> I have downloaded dlmalloc and statically compiled it into the test program

dlmalloc is an older version of the allocator in use by glibc (once written by
Doug Lea, now maintained largely by Wolfram Gloger).

> to see what difference it makes.  Interestingly it only appears to expand
> the sbrk value by a much more modest amount  - rounded to the nearest 4k it
> seems.   It would seem that this version of malloc is much more 'user memory'
> friendly!!

It's probably much less efficient as well. `User memory' friendliness in
terms of allocating a small arena is largely a waste of time, because
allocated-with-sbrk()-but-unwritten memory never consumes actual storage
space unless you write to it, even if overcommitting is off.

The only negative consequence of allocating a bigger arena than
necessary is that if you're scattering allocations at random throughout
that arena it might consume more pages than necessary: but the glibc
allocator is good enough not to scatter allocations at random unless it
has to.


You really can't judge the performance of the glibc malloc() without
reading the source and preferably instrumenting it and running
testcases. Reasoning on the basis of the return value of mallinfo() is
just hopeless.

-- 
`Some people don't think performance issues are "real bugs", and I think 
such people shouldn't be allowed to program.' --- Linus Torvalds
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list