diff options
| author | chai <chaifix@163.com> | 2020-09-09 20:09:27 +0800 |
|---|---|---|
| committer | chai <chaifix@163.com> | 2020-09-09 20:09:27 +0800 |
| commit | 229a3937a3b99a175b551e28d09b9a45d37c44f7 (patch) | |
| tree | 3dce1ff5cbb81fe9d6a774c77878a48146ead8d0 /src/lua51/lgc.h | |
| parent | 77ac95b9985f5669d6659bfb54728786d28c2ef0 (diff) | |
*misc
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)); } |
