Stack grows exponentially.
For instance:
local function f(c)
print(c, ll.GetFreeMemory())
f(c + 1)
end
f(1)
--[[
1 128697
.
.
.
1581 29337 -- stack full, going to grow by a lot
not enough memory
]]
Or:
local t = table.create(6000, true)
print(ll.GetFreeMemory()) -- > 32608
unpack(t, 1001, 2000) -- not enough free slots, growing by 1000 (and 5 extra)
print(ll.GetFreeMemory()) -- > 16528
unpack(t, 951, 2050) -- not enough free slots, going to grow by 1100
-- although 1000 are empty and only needs 100 more
-- > too many results to unpack
No limit in unpack(), it's memory:
local t = table.create(4000, true)
print(ll.GetFreeMemory()) -- > 64650
unpack(t, 2, 3999) -- no limit to unpacking, limit is memory
print(ll.GetFreeMemory()) -- > 602
Could stack resize be capped, in a similar way than the array resize? something like:
size = min( calculated, used + needed + 128 )
Stack grows exponentially.
For instance:
Or:
No limit in
unpack(), it's memory:Could stack resize be capped, in a similar way than the array resize? something like:
size = min( calculated, used + needed + 128 )