summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-11-23 14:17:28 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-11-23 14:17:28 -0300
commit9a77f57edc5cc24c2ab71d416b7481a5679e3869 (patch)
tree5eee1c3da965294d18a599d0b8674f2df402490e
parentbe908a7d4d8130264ad67c5789169769f824c5d1 (diff)
downloadlua-github-9a77f57edc5cc24c2ab71d416b7481a5679e3869.tar.gz
Stop GC while building initial state
-rw-r--r--lua.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lua.c b/lua.c
index 7f7dc2b2..715430a0 100644
--- a/lua.c
+++ b/lua.c
@@ -633,7 +633,8 @@ static int pmain (lua_State *L) {
}
luaL_openlibs(L); /* open standard libraries */
createargtable(L, argv, argc, script); /* create table 'arg' */
- lua_gc(L, LUA_GCGEN, 0, 0); /* GC in generational mode */
+ lua_gc(L, LUA_GCRESTART); /* start GC... */
+ lua_gc(L, LUA_GCGEN, 0, 0); /* ...in generational mode */
if (!(args & has_E)) { /* no option '-E'? */
if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */
return 0; /* error running LUA_INIT */
@@ -665,6 +666,7 @@ int main (int argc, char **argv) {
l_message(argv[0], "cannot create state: not enough memory");
return EXIT_FAILURE;
}
+ lua_gc(L, LUA_GCSTOP); /* stop GC while buidling state */
lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */
lua_pushinteger(L, argc); /* 1st argument */
lua_pushlightuserdata(L, argv); /* 2nd argument */