lua-users home
lua-l archive

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

Hi David,

a week or two ago I've started use lua 4.1 as scripting engine for my
windows server application. It's a simple server for P2P share comunity with
ability to handle more than 1000 simultaneous connections. Now it seems that
I got a serious problems with memory. When the scripting engine is
dissabled, everything goes just fine but with just one script running
(calling it's functions many times per second, pushing new global tables
with strings etc. etc.) the ram usage grows with time. Im sure I have no
memory leaks (analyzed with MemorySleuth and BoundsChecker). Also when all
Lua virtual machines are stopped and closed the memory falls down to it's
So I think the problem is with garbage collection. I've read about your
patch at the lua news board. I looks that such modification is exactly what
would help me very much. But I don't know if the patch is available for
"third" persons.

Thanks for any answer.


----- Original Message -----
From: "David Bhowmik" <>
Newsgroups: gmane.comp.lang.lua.general
Sent: Monday, October 21, 2002 2:00 PM
Subject: RE: Garbage collection

> Thanks for your feedback Joshua. I have now written a patch for lua to
> its garbage collection into a pseudo reference counting system, and this
> 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
> Is there anything to watch out for?
> Dave
> -----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.
> Seriously.
> 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.  :(
> -Josh