lua 垃圾回收
垃圾回收
lua 自动进行垃圾收集,可不用手动操作
collectgarbage(opt, arg) :垃圾收集,arg可选
This function is a generic interface to the garbage collector. It performs
different functions according to its first argument, opt:
* 该函数用于垃圾收集,第一个参数可控制垃圾回收动作
# collect:做一次完整的垃圾收集循环,默认
Performs a full garbage-collection cycle. This is the default option.
# stop:停止垃圾收集器的运行,直到显示开启垃收集器
Stops automatic execution of the garbage collector. The collector
will run only when explicitly invoked, until a call to restart it.
# restart:重新开启垃圾回收器,使其自动运行
Restarts automatic execution of the garbage collector.
# count:以K(kb)为单位返回 Lua 使用的总内存数
Returns the total memory in use by Lua in Kbytes. The value has a
fractional part, so that it multiplied by 1024 gives the exact
number of bytes in use by Lua.
# step:单步运行垃圾收集器,步长由arg控制
Performs a garbage-collection step. The step "size" is controlled by arg.
With a zero value, the collector will perform one basic (indivisible) step