WoW:USERAPI EraseTable: Difference between revisions

m
WW:MOS
mNo edit summary
m (WW:MOS)
Line 1: Line 1:
{{localuserfunc}}
{{localuserfunc}}


Erases a table, often a good way to reduce garbage creation. Note that erasing a table can be more expensive than letting the GC system reclaim it, so one might prefer simply reallocating a new empty table. Also note that a hash (as opposed to a 1..n integer-index) will NEVER SHRINK. Each key you ever used will use ~40 bytes and keep doing so until the table is destroyed. If you re-use the same keys this is obviously a nonissue.
'''EraseTable''' erases a table, often a good way to reduce garbage creation. Note that erasing a table can be more expensive than letting the GC system reclaim it, so one might prefer simply reallocating a new empty table. Also, note that a hash (as opposed to a 1..n integer-index) will NEVER SHRINK. Each key you ever used will use ~40 bytes and keep doing so until the table is destroyed. If you re-use the same keys this is obviously a nonissue.


For more details on the inner workings of tables and when to reallocate vs when to erase, see [[Lua object memory sizes]] and it's [[Talk:Lua object memory sizes|talk page]].
For more details on the inner workings of tables and when to reallocate vs when to erase, see [[Lua object memory sizes]] and it's [[Talk:Lua object memory sizes|talk page]].
Anonymous user