Force garbage collection.
This commit is contained in:
parent
4575c5c0e6
commit
aefc390cc9
1 changed files with 10 additions and 8 deletions
18
mapgen.lua
18
mapgen.lua
|
@ -468,14 +468,6 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
vm:update_liquids()
|
vm:update_liquids()
|
||||||
vm:write_to_map()
|
vm:write_to_map()
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -493,6 +485,16 @@ end
|
||||||
|
|
||||||
|
|
||||||
local function pgenerate(...)
|
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, ...)
|
local status, err = pcall(generate, ...)
|
||||||
if not status then
|
if not status then
|
||||||
print(dump(err))
|
print(dump(err))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue