Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a (simple) way to get the memory usage of a Lua table?

I'd like to find out how much memory a Lua table is using - without iterating through the table contents and counting up the usage. Is there a Lua 5.1 function or 3rd party library that could help with this.

like image 220
user295625 Avatar asked Mar 17 '10 11:03

user295625


2 Answers

You can monitor the memory usage of Lua by calling collectgarbage("count") or gcinfo() in the appropriate locations throughout the code (e.g. before and after insert operations). There's no trivial way to get the size of a table.

like image 105
deorst Avatar answered Nov 15 '22 10:11

deorst


There is no function for this task. Why do you want to do this? What are you trying to achieve?

like image 41
lhf Avatar answered Nov 15 '22 09:11

lhf