Re: Calculating estimate for size of a lua table
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Calculating estimate for size of a lua table
- From: Xmilia Hermit <xmilia.hermit@...>
- Date: 2022年8月13日 19:32:21 +0200
Lars Müller:
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.
It is more like 16 bytes for the list part as PUC Lua uses tagged values
(8 byte value + 1 byte tag) which is rounded up to 16.
For the hast part it is likely 24. (2 * 8 byte value (for value + key) +
2 * 1 byte tag (for value + key) + 4 byte link to next element when
multiple have the same hash rounded up to 24).
And the empty table has likley 64 byte of a constant cost.
So in total something like 64 + 16 * array_size + 24 * hash_size where
the sizes are power of two's.
Regards,
Xmilia