lua-users home
lua-l archive

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

I would assume the following:

For the list part: 8 bytes for each entry.
For the hash part: 8 bytes (key) + 8 bytes (value) for each entry.
Since both hash part and list part seem to grow exponentially with
powers of two, substitute ceil(log_2(len)) for the length of both parts.

The most reliable way to find out is to benchmark memory usage using
collectgarbage"count" though. For these purposes, you will probably want
to first create a table to get all constants into memory, then count the
initial memory including the memory for string constants etc, then
create *many* objects, then count again, take the difference and divide
that by the number of objects you created.

On 13.08.22 18:49, Marcus Mason wrote:
Hello list,

Does anyone know of a back of the envelope calculation for the rough
size of a lua 5.4 table?
I am dealing with a system which creates lots of tables and want to
work out how much X of one particular type of object is costing me
memory wise.