SatheeshJM
SatheeshJM

Reputation: 3643

Lua - Count the no. of references to a table

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?

Upvotes: 3

Views: 2026

Answers (1)

lhf
lhf

Reputation: 72312

You can find all references to a Lua value using the debug library. See these messages:

The luatraverse library found in the below link solves this nicely! http://code.matthewwild.co.uk/luatraverse/summary

Upvotes: 5

Related Questions