[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Userdata environment
- From: Ralph Hempel <rhempel@...>
- Date: Fri, 04 Apr 2008 10:07:21 -0400
Petr Kodl wrote:
On Win32 / Lua 5.1.3 the loop test published on this thread shows some
With gcpause set to 200 the memory growth unbounded.
With gcpause set to 199 the unbound growth is gone and the memory
fluctuates around 4-6MB.
As the number approaches 190 the behavior starts to match linux version
with sizeof(TValue) aligned to 12 bytes and becomes relatively
insensitive to the value change.
I'm following this thread with great interest. I've got Lua running
reasonable well on an _extremely_ memory constrained platform with
a heap of about 48K (yes K) of RAM.
I've had to emply various tricks to keep memory use down including:
1. Setting the string buffer size down to 32 bytes so that as
strings are built up we don't try to grab "big" chunks
2. Limit the number of stack slots, local vars, upvalues in a function
3. Set the gc threshold to 105 or 110. It's unacceptable to wait until
memory use doubles before collecting garbage if I've only got 48K
available and I am using 38K :-)
I must admit I've read and reread the garbage collection section in
the original PiL and have gone over the code more times than I like
and it's still a bit magic. I still don't fully understand how
the GCMUL and GCPAUSE affect the overall performance, and how
the GCSTEPSIZE might be modified to help. (It's not in luaconf.h so
I have not played with it)
It would be nice if the Lua garbage collector was able to figure out
if it was running up against a fixed ceiling of memory use...
Also, the biggest issue I'm seeing is that as Lua runs for longer
periods of time, the heap tends to get really fragmented. So Lua
may report using 20K or so, but in fact the heap may not have
even a 1K section available as a contiguous block.