lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Edgar Toernig wrote:
> Something's fishy!  I got the problem too (x86-linux libc5).
> lua5 -e 's="" for i=1,10000 do s=s.."x" end'
> grows to >40MB (100000 is too much for my system) with only 200kb in
> actual use (reported by mallinfo).  It seems, the heap is totally
> fragmented with realloc unable to reuse anything at all (but nblocks
> seems to be right!).

I found the problem.  At least here it's a bug in realloc(x,0).  It's
not an alias for free(x).  It truncates x to a fixed small size (and
even returns that address).  Of course, that will prohibit any defrag-
mentation.  Replacing the freeing l_realloc in lmem.c by a free(block)
cures the problem.

Ciao, ET.