[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua memory usage for games console
- From: "Stuart Middleton" <stuart.middleton@...>
- Date: Fri, 12 Sep 2003 17:17:28 +0100
Hi All,
We are currently evaluating lua as a replacement for our internal scripting
attempt. My initial evaluation (only 1 day) shows that each loaded script
uses a load of memory.
i.e.
xpos = 20.423987987234
ypos = 30.923874982343
zpos = 40.982374982734
function GetAllPos()
return xpos+ypos+zpos;
end
function GetXPos()
return xpos;
end
function GetYPos()
return ypos;
end
function GetZPos()
return zpos;
end
which is pitifully small (and does nothing useful) uses 822 bytes of memory.
I am using precompiled scripts with the debug info stripped. This memory
does not included the mem used to load the script in the first place.
As far as I can see its because of the over bloated structures inside lua.
For instance GCObject uses 72 bytes just because it's a union of common
types one of which being Proto which is 72 bytes long. So at a guess each
variable will be at least 72 bytes long?
Before I go rewriting how lua handles its internal structures or give up on
it completely I wondered if anyone out there has reworked the system to use
minimal memory.
As comparison a simple test script like this in our system would use about
250 bytes with new instances of the same script using < 100 bytes.
Any help would be much appreciated.
While I'm at it I have another question.
We will need to load multiple scripts, hundreds in fact, most of which would
be copies of each other. They all need to maintain their own global (or file
local) variables. Has anyone done this before? I guessed you would use
either the threading system or a new state for each (we are not
multi-threaded) but the overhead for a new system or even a new thread each
time is a bit over the top. Also our internal system was written so we could
load a script once and create instances of it with new variables but pointer
to the functions in just 1 copy of the byte code.
Any idea's
Hope you can help
Stuart Middleton (lua newbie)