[uClibc]malloc and malloc-simple

Erik Andersen andersen at codepoet.org
Fri Dec 21 17:10:01 UTC 2001


On Fri Dec 21, 2001 at 04:59:27PM +0100, Adrian von Bidder wrote:
> Heyho!
> 
> On a sample of one program (ok, nut much, I know):
> malloc-simple: program runs, with >300k of free memory at every point.
> malloc: fails quite quickly (after only 10-20 mmap syscalls coming from
> malloc) on out of memory.

I believe this may in fact be due to the way the uCliux kernels
provide mmaped memory to user space.  I think the kernel
allocator is doing something sneaky (like not returning memory
aligned on a PAGESIZE boundaries so it can hide some allocation
metadata).  Whatever it is, it doesn't seem to play nicely with
the "malloc" uClibc allocation scheme.

> This is on arm7tdmi with total 1M RAM (600k free at the beginning) and
> with gcc-3.0.2.
> 
> Is it generally advised to use malloc-simple on non-mmu systems?

Yes.  In theory, using malloc instead of malloc-simple should
reduce memory fragmentation and reduce the number of allocations.
In practice, on non-mmu systems this doesn't seem to be the case,
as you have seen.  It could stand to have some eyeballs looking
at it sometime,

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--




More information about the uClibc mailing list