lua-users home
lua-l archive

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


Michel Machado wrote:
>
>   I didn't understand this behavior of Lua GC. My Linux box:

It has very little to do with the garbage collector.  It's
a feature of malloc/free.

> [First test: 
>  gcinfo 14k, RSS 620k
>  gcinfo 197m, RSS 192m
>  gcinfo 14k, RSS 736k
> ]

That shows that your malloc tries hard to give free memory
back to the system (and was lucky).  Not a common feature of
malloc packages.

> [Another test:
>  gcinfo 14k, RSS 620k
>  gcinfo 771m, RSS 830m
>  gcinfo 14k, RSS 382m
> ]

Here, malloc was unable to give everything back.  There are
a couple of reasons why this is possible: fragmented memory,
wrong pool that can only give back unused memory at the end
of the pool, ...

There's nothing wrong with Lua.  Is a fundamental problem
on a lot of systems.  The positiv thing about this "mis-
behaviour" is that future allocations are faster because
malloc doesn't have to call the kernel for new memory ;-)
(Because of this some people even consider the "give back"
a misfeature - under worst case every malloc/free can go
through the kernel and will be dead slow.)

Ciao, ET.