简体   繁体   English

卢阿-数数。 表引用

[英]Lua - Count the no. of references to a table

The Lua docs say Lua文档说

When a program has no references to a table left, Lua memory management will eventually delete the table and reuse its memory. 当程序没有对表的引用时,Lua内存管理最终将删除该表并重新使用其内存。

My question is : Is it possible to count the no of references to a particular table during runtime? 我的问题是:是否可以在运行时计算对特定表的引用数?

You can find all references to a Lua value using the debug library. 您可以使用调试库找到对Lua值的所有引用。 See these messages: 查看以下消息:

The luatraverse library found in the below link solves this nicely! 在下面的链接中找到的luatraverse库很好地解决了这个问题! http://code.matthewwild.co.uk/luatraverse/summary http://code.matthewwild.co.uk/luatraverse/summary

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM