Skip to content

Stack grows into "out of memory" without need #82

@Suzanna-Linn

Description

@Suzanna-Linn

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 )

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions