[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Multiple luaL_loadfile()/lua_pcall() and persistance
- From: Laurent FAILLIE <l_faillie@...>
- Date: Mon, 23 Jul 2018 09:17:06 +0000 (UTC)
Hello,
I'm on a tool that load then execute several Lua scripts so I have many call to luaL_loadfile()/lua_pcall() pairs. My question is about code persistence.
3 examples :
--- script1.lua ---
print "I'm doing very interesting stuffs"
---
--- script2.lua ---
function toto()
print "even more interesting stuffs"
end
---
--- script3.lua ---
print "Yeah, I'm here"
function tata()
print "I'm the most interesting one"
end
---
My assertions are the following :
1/ content of script1 is only one shot so it is collected and resource are freed
2/ toto() and tata() kept, ready to be called by other code.
3/ after loading/calling all those 3 script, in Lua's memory only toto() and tata() remain, and "external" prints get collected after execution.
Am I right ?
Thanks
Laurent