lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

On Sun, 27 Sep 2020 at 02:42, 孙世龙 sunshilong <sunshilong369@gmail.com> wrote:
>
> Hi, list
>
> Is there a (simple) way to get the memory usage of a Lua object (e.g table)?

Simple? No :)

But yes, you can use this module:
https://luarocks.org/modules/siffiejoe/getsize to tell you the size of
the table's internal data structures.

However in most applications if there are objects that are referenced
by the table (and possibly *only* by the table) you likely want to
include the size of those objects too.

> 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.