瀏覽代碼

loop of 'dostring' may never reclaim memory

Roberto Ierusalimschy 24 年之前
父節點
當前提交
42224ca553
共有 4 個文件被更改,包括 12 次插入5 次删除
  1. 4 0
      bugs
  2. 4 2
      ldo.c
  3. 2 2
      lgc.c
  4. 2 1
      lgc.h

+ 4 - 0
bugs

@@ -255,3 +255,7 @@ Thu Feb  1 11:55:45 EDT 2001
 >> lua_pushuserdata(L, NULL) is buggy
 (by Edgar Toernig; since 4.0)
 
+** ldo.c
+Fri Feb  2 14:06:40 EDT 2001
+>> «while 1 dostring[[print('hello\n')]] end» never reclaims memory
+(by Andrew Paton; since 4.0b)

+ 4 - 2
ldo.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 1.120 2001/02/01 17:40:48 roberto Exp roberto $
+** $Id: ldo.c,v 1.121 2001/02/02 15:13:05 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -251,7 +251,9 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
   int status;
   LUA_LOCK(L);
   p.z = z; p.bin = bin;
-  luaC_checkGC(L);
+  /* before parsing, give a (good) chance to GC */
+  if (G(L)->nblocks/8 >= G(L)->GCthreshold/10)
+    luaC_collectgarbage(L);
   old_blocks = G(L)->nblocks;
   status = luaD_runprotected(L, f_parser, &p);
   if (status == 0) {

+ 2 - 2
lgc.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 1.84 2001/02/01 17:40:48 roberto Exp roberto $
+** $Id: lgc.c,v 1.85 2001/02/02 15:13:05 roberto Exp roberto $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -375,7 +375,7 @@ void luaC_collect (lua_State *L, int all) {
 }
 
 
-static void luaC_collectgarbage (lua_State *L) {
+void luaC_collectgarbage (lua_State *L) {
   markall(L);
   invalidaterefs(G(L));  /* check unlocked references */
   luaC_collect(L, 0);

+ 2 - 1
lgc.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.h,v 1.7 1999/11/22 13:12:07 roberto Exp roberto $
+** $Id: lgc.h,v 1.8 2000/10/02 14:47:43 roberto Exp roberto $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -12,6 +12,7 @@
 
 
 void luaC_collect (lua_State *L, int all);
+void luaC_collectgarbage (lua_State *L);
 void luaC_checkGC (lua_State *L);