lua-users home
lua-l archive

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


Trevor Powell wrote:
this is
what I wanted: "just specify the amount of wasted memory to be tolerated
as a percentage of in-use memory, with higher tolerance translating to
lower GC overhead".

Whereas we, working on a very limited hardware platform, need to be able
to limit Lua's memory usage absolutely;  we pre-allocate a small block of
memory (currently about 60k), which we use exclusively for Lua.  We do
this so that Lua's frequent requests for very small blocks of memory don't
cause memory fragmentation out in the heap.

When you only have 32 megabytes of RAM available, and load files that are
often as much as 18 megabytes in size, you get paranoid about heap
fragmentation very quickly.  :)

We currently do this by explicitly resetting Lua's garbage collection
threshhold immediately after each call into Lua;  that's the only way I
could find to keep Lua's garbage collection threshhold constant, since Lua
multiplies its gc threshhold by two every time it performs garbage
collection.

I've already completed a project that uses Lua on a PS2, and in fact that's what I was working on when I wrote about the dream garbage collector.

Incremental GC (the subject of this thread) is there to reduce worst case memory and CPU usage. It's mostly orthogonal to the issue of memory fragmentation.

-John


--
http:// ift ile.org/