When calling
ll.GetUsedMemory()
or
ll.GetFreeMemory()
immediately after some memory operation:
-- memory miscount
local tab = {}
local mem = ll.GetUsedMemory()
tab = table.create(32, true)
print(ll.GetUsedMemory() - mem) -- > 512
tab = table.move(tab, 1, 1, 1, {})
print(ll.GetUsedMemory() - mem) -- > 560 -- should be 16
Adding something that yields works well (it seems that yielding cleans things):
-- yielding
local tab = {}
local mem = ll.GetUsedMemory()
tab = table.create(32, true)
print(ll.GetUsedMemory() - mem) -- > 512
tab = table.move(tab, 1, 1, 1, {})
for _ = 1, 1 do end -- yielding
print(ll.GetUsedMemory() - mem) -- > 16
Also calling the function twice (perhaps because they yield at the end):
-- calling twice
local tab = {}
local mem = ll.GetUsedMemory()
tab = table.create(32, true)
print(ll.GetUsedMemory() - mem) -- > 512
tab = table.move(tab, 1, 1, 1, {})
local used, used = ll.GetUsedMemory(), ll.GetUsedMemory()
print(used - mem) -- > 16
Could
ll.GetUsedMemory()
and
ll.GetFreeMemory()
yield at the start to update the memory?