Force garbage collection.

This commit is contained in:
Duane 2016-07-30 21:03:58 -05:00
parent 4575c5c0e6
commit aefc390cc9

View file

@ -468,14 +468,6 @@ local function generate(p_minp, p_maxp, seed)
vm:update_liquids()
vm:write_to_map()
end
-- Deal with memory issues. This, of course, is supposed to be automatic.
minetest.after(0, function()
if math.floor(collectgarbage("count")/1024) > 400 then
print("Fun Caves: Manually collecting garbage...")
collectgarbage("collect")
end
end)
end
@ -493,6 +485,16 @@ end
local function pgenerate(...)
if math.floor(collectgarbage("count")/1024) > 400 then
print("Fun Caves: Manually collecting garbage...")
collectgarbage("collect")
-- Slow down to allow time to free memory.
local clock = os.clock
local t0 = clock()
while clock() - t0 <= 2 do end
end
local status, err = pcall(generate, ...)
if not status then
print(dump(err))