问题
The Lua docs say
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?
回答1:
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
The luatraverse library found in the below link solves this nicely! http://code.matthewwild.co.uk/luatraverse/summary
来源:https://stackoverflow.com/questions/11366693/lua-count-the-no-of-references-to-a-table