-- This script intentionally tries to exhaust memory
-- When run with a 512KB limit, it should fail before completing

local t = {}
local i = 0

while true do
    i = i + 1
    -- Each string is 100KB
    t[i] = string.rep("x", 100000)

    -- Safety check - if we get past 100 iterations with 512KB limit,
    -- something is wrong
    if i > 100 then
        error("FAIL: Should have hit memory limit by now (allocated ~10MB)")
    end
end

-- Should never reach here
error("FAIL: Memory limit not enforced")
