卢阿-数数.对表的引用 [英] Lua - Count the no. of references to a table
本文介绍了卢阿-数数.对表的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Lua文档说
当程序没有对剩余表的引用时,Lua内存 管理层最终将删除该表并重新使用其内存.
When a program has no references to a table left, Lua memory management will eventually delete the table and reuse its memory.
我的问题是:是否可以在运行时计算对特定表的引用数?
My question is : Is it possible to count the no of references to a particular table during runtime?
推荐答案
您可以使用调试库找到对Lua值的所有引用.查看以下消息:
You can find all references to a Lua value using the debug library. See these messages:
- http://lua-users.org/lists/lua-l/2012-03/msg00479.html
- http://lua-users.org/lists/lua-l/2012-04/msg00758.html
- http://lua-users.org/lists/lua-l/2012-03/msg00479.html
- http://lua-users.org/lists/lua-l/2012-04/msg00758.html
在下面的链接中找到的luatraverse库很好地解决了这个问题! http://code.matthewwild.co.uk/luatraverse/summary
The luatraverse library found in the below link solves this nicely! http://code.matthewwild.co.uk/luatraverse/summary
这篇关于卢阿-数数.对表的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文