lua-users home
lua-l archive

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

Thanks for your feedback Joshua. I have now written a patch for lua to turn
its garbage collection into a pseudo reference counting system, and this is
working swimingly. I was wondering what platforms your game was available
for because we are currently working on PC but are considering porting out
engine to the PS2 and XBox. Do you know how lua performs on these platforms?
Is there anything to watch out for?


-----Original Message-----
From: Joshua Jensen []
Sent: 11 October 2002 17:44
To: Multiple recipients of list
Subject: RE: Garbage collection

> I am having trouble with Lua garbage collection. I am using 
> Lua as an agent system for a real time game. Basically the 
> mark and sweep system takes to long. Having a small threshold 
> requires garbage collecting regularly, which means marking a 
> lot of data regularly and cleaning up a little of it. The 
> marking takes to long to do so regularly. Having a high 
> threshold requires marking less regularly which is better but 
> cleaning up loads of data in one sweep, which takes to long. 
> There is no good balance here. Has anyone found a way around this?

Don't cause anything to allocate during the real-time.


It was the only way to ship Amped: Freestyle Snowboarding.  No closures
could be generated on the fly.  No tables could be generated on the fly.
No strings could be generated on the fly.  The allocations were
identified, and pregenerated before the real-time ran.

So, instead of filling in myTable like this in the real-time:

myTable = {}
myTable.Var1 = 5
myTable.Var2 = "Hi"

myTable was made global, generated before the real-time loop, with all
the possible fields in place.

In other words, either make the necessary changes to your real-time Lua
codebase (by breakpointing the realloc function for Lua to determine
where memory allocations are), or don't count on using Lua during your
real-time.  :(