LUA Memory requirement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

LUA Memory requirement

Christophe Gimenez
What is the difference in memory requirement by :

- A single script (10000 lines)
- The same amount of code used by 100 scripts of 100 lines

Thus, how much memory a "LUA state" consumes (don't take in account the memory used by the vars of the script) ?

Thanks

Reply | Threaded
Open this post in threaded view
|

Re: LUA Memory requirement

Erik Hougaard
Christophe Gimenez wrote:
> Thus, how much memory a "LUA state" consumes (don't take in account the memory used by the vars of the script) ?

Take a look at lmem.c there are some debug settings that will give you
total memory allocated and number of blocks.

If this does not fullfill your requirements it should be quite easy to
modify lmem.c to get the information you need. All memory management in
Lua goes thru this module (alloc/realloc/free) ...

/Erik

Reply | Threaded
Open this post in threaded view
|

AW: LUA Memory requirement

Alexander Jorias
In reply to this post by Christophe Gimenez
It should be quite similar. Multiple calls to lua_dofile
do not create multiple lua_states. They just add the
scripts to the 'global nametable' of the lua state.

> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [[hidden email]
> Auftrag von Christophe Gimenez
> Gesendet: Montag, 20. März 2000 12:16
> An: Multiple recipients of list
> Betreff: LUA Memory requirement
>
>
>
> What is the difference in memory requirement by :
>
> - A single script (10000 lines)
> - The same amount of code used by 100 scripts of 100 lines
>
> Thus, how much memory a "LUA state" consumes (don't take in
> account the memory used by the vars of the script) ?
>
> Thanks

Reply | Threaded
Open this post in threaded view
|

Multiple Scripts, Pausing, Threads, and Persistant Variables

Sean Thomas Middleditch
In reply to this post by Erik Hougaard
I'm new to Lua, and have a quick question (ok, a few...):  Is it possible to
load a precompiled script, and then only run a PORTION of that script, halt,
run some other code, then return where I left off?

Basically, I'm making a game that will start multiple scripts and have them
run.  However, some of these scripts may do things like say they're going to
wait for this or that to happen... I could have the wait functions call the
game loop (what I'm looking into doing right now), but I'd rather that the
game loop control the scripts, not the scripts control the game loop.

Basically, what I'm looking for is a way to say, "OK, here is this instance
of this script... it has called the wait_for_whatever function, which set a
'pause' flag or somesuch, so the call to run the script returns and the C++
program continues to execute.  The next game loop iteration, it looks at
it's currently running scripts, and tells them to continue.  The 'paused'
script re-enters the function that caused it to pause.  The function does it
checks, realizes the event has occured, and unsets the 'pause' attribute, so
the script continues its execution."

Another question is does Lua have "persistant" global varibales?  Can I, for
example, have a `do_file ("scripta.lua");' in my C++ code, have that script
set variable pglobal to 25, and on another call to `do_file
("scripta.lua");' or a call to `do_file ("scriptb.lua");' have pglobal still
defined with a value of 25?  If not, I'll just implement it through C
extensions... ;-)

Also, is Lua thread safe?  I recall seeing a version specifically made for
threads; is it compatible with other Lua add-ons like the socket add-on?  My
game will be a MUD, and there may be several servers running at once to deal
with large player loads, and the servers will need to cooperate properly.

Sorry for the near incoherant babbling, I'm not all that great at explaining
things... :)

Thanks,
Sean Middleditch

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Scripts, Pausing, Threads, and Persistant Variables

Erik Hougaard
Sean Middleditch wrote:
> Another question is does Lua have "persistant" global varibales?  Can I, for
> example, have a `do_file ("scripta.lua");' in my C++ code, have that script
> set variable pglobal to 25, and on another call to `do_file
> ("scripta.lua");' or a call to `do_file ("scriptb.lua");' have pglobal still
> defined with a value of 25?  If not, I'll just implement it through C
> extensions... ;-)

YES!
 
> Also, is Lua thread safe?  I recall seeing a version specifically made for
> threads; is it compatible with other Lua add-ons like the socket add-on?  My
> game will be a MUD, and there may be several servers running at once to deal
> with large player loads, and the servers will need to cooperate properly.

Well there is a luaMT thats a implementation of Posix threads - I'm not
sure its updated for 3.2 ?? . I have also made a multi-state version of
Lua thats thread safe because your would be running each thread in its
own state. (Ofcause then its without sharing any information).

/Erik

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Scripts, Pausing, Threads, and Persistant Variables

Sean Thomas Middleditch
----- Original Message -----
From: Erik Hougaard <[hidden email]>
To: Multiple recipients of list <[hidden email]>
Sent: Monday, March 20, 2000 12:05 PM
Subject: Re: Multiple Scripts, Pausing, Threads, and Persistant Variables


> Sean Middleditch wrote:
> > Another question is does Lua have "persistant" global varibales?  Can I,
for
> > example, have a `do_file ("scripta.lua");' in my C++ code, have that
script
> > set variable pglobal to 25, and on another call to `do_file
> > ("scripta.lua");' or a call to `do_file ("scriptb.lua");' have pglobal
still
> > defined with a value of 25?  If not, I'll just implement it through C
> > extensions... ;-)
>
> YES!

Yes, I found that out earlier today... I feel dumb now... ;-)

> > Also, is Lua thread safe?  I recall seeing a version specifically made
for
> > threads; is it compatible with other Lua add-ons like the socket add-on?
My
> > game will be a MUD, and there may be several servers running at once to
deal
> > with large player loads, and the servers will need to cooperate
properly.
>
> Well there is a luaMT thats a implementation of Posix threads - I'm not
> sure its updated for 3.2 ?? . I have also made a multi-state version of
> Lua thats thread safe because your would be running each thread in its
> own state. (Ofcause then its without sharing any information).

Ick, I'm afraid that won't help... I'd need them to share information...
::sigh::  And no, LuaMT is based on Lua 3.1.  ::bigger sigh::

> /Erik

Sean Middleditch