lua-users home
lua-l archive

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

On 12/17/2014 12:47 PM, Lev wrote:
I have C program that calls various Lua scripts say 10 times a second.

Question is that is it cheap to do luaL_newstate() and luaL_openlibs(L) and
call the script and then lua_close(L) each time I run my Lua script, or
shall I call luaL_newstate() and luaL_openlibs(L) at the beginning of my
application, and call lua_close(L) when I exit?

Or ... must I call luaL_newstate() and luaL_openlibs(L) before each script


Depends on the usecase. Normally I would call luaL_newstate only once.
And then run all the scripts in the same state. Now there is one issue here,
if your scripts use globals you need to ensure that you don't have any conflicts.