diff options
Diffstat (limited to 'src/lua51/lgc.h')
| -rw-r--r-- | src/lua51/lgc.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lua51/lgc.h b/src/lua51/lgc.h index 9fa686a..83007ac 100644 --- a/src/lua51/lgc.h +++ b/src/lua51/lgc.h @@ -4,6 +4,8 @@ ** See Copyright Notice in lua.h */ +//c 垃圾回收 + #ifndef lgc_h #define lgc_h @@ -78,12 +80,15 @@ // g->currentwhite ^ WHITEBITS是 otherwhite #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) - +// 自动触发回收内存,在每次调用内存分配相关API时进行 +// 触发条件是当前分配的内存大于阈值GCthreshold +// 自动触发不可控,很多人选择关闭它,方法是通过设置一个很大的GCthreshold比如(~0) #define luaC_checkGC(L) { \ condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ if (G(L)->totalbytes >= G(L)->GCthreshold) \ luaC_step(L); } +//c 避障相关操作,分为向前避障 luaC_barrier luaC_objbarrier 和向后避障 luaC_barriert luaC_objbarriert #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ luaC_barrierf(L,obj2gco(p),gcvalue(v)); } |
