[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Loading Scripts
- From: "Nick Trout" <nick@...>
- Date: Fri, 23 May 2003 14:48:39 -0700
Put your code in a function
function count
value = (value or 1) + 1
print( "this script has been executed ".. value .."
times\r\n");
end
count()
To delete it:
count = nil -- value is global and remains
GC will collect function body or you can force it collectgarbage().
Alternatively if you don't want to have to delete each function you can
execute the script into a namespace and delete that. Look back through
the lua-l mailing list archives (or maybe on the wiki) for code to do
this. I think Wim or Peter Shook have demonstrated this recently.
Nick
P.S. Please post in plain text format.
-----Original Message-----
From: Andrew Teirney [mailto:andrew@teirney.net]
Sent: Friday, May 23, 2003 2:33 PM
To: Lua list
Subject: Loading Scripts
Hi there,
I have an application where i am loading large amounts of scripts as
needed, currently this is though my own chunk loader which loads then
off my rom flash fs. These little scripts perform simple rules for
generating events. What i have noticed is that i load a chunk, it
executes, then the chunk ends then there seems to be more memory used, i
the same chunk again and then it uses up more memory, then usage is not
consistent, but around 2K every time... the script is as below. What i
am wanting to know is how after running the below script can i free any
internal structures related to that script, or even just the trash the
last chunk loaded, or all chunks in memory, i still want to preseve all
the gobal variables and so forth so a lua_close is not possible. If
anyone can offer some help that would be greatly appreciated.
if value == nil then
value = 1
else
value = value + 1
end
print( "this script has been executed ".. value .." times\r\n");
Many Thanks,
Andrew Teirney