mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-11-28 10:13:50 +01:00
try to circumvent Out Of Memory error (Win64)
See https://gitlab.com/4w/mtimer/issues/7
This commit is contained in:
parent
c74dcf708a
commit
abc8fd5b55
3
init.lua
3
init.lua
@ -16,6 +16,9 @@ local S = minetest.get_translator('mtimer')
|
||||
mtimer = {
|
||||
translator = S,
|
||||
dialog = {},
|
||||
config = {
|
||||
manual_gc = minetest.settings:get_bool('mtimer_manual_gc', false)
|
||||
},
|
||||
meta = {
|
||||
visible = { key = 'mtimer:visible', default = 'true' },
|
||||
position = { key = 'mtimer:position', default = 'bl' },
|
||||
|
10
settingtypes.txt
Normal file
10
settingtypes.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Manual Lua garbage collection
|
||||
#
|
||||
# This setting addresses a bug that reportedly happens
|
||||
# on Windows. Lua seems to run out of memory. When this
|
||||
# setting is enabled mTimer runs the Lua garbage
|
||||
# collector automatically every 10 seconds.
|
||||
#
|
||||
# If you’re on Windows and your game does not crash
|
||||
# simply ignore this setting.
|
||||
mtimer_manual_gc (Perform manual Lua garbage collection) bool false
|
@ -1,5 +1,6 @@
|
||||
local m = mtimer
|
||||
local update_timer = m.update_timer
|
||||
local manual_gc = m.config.manual_gc
|
||||
local connected_players = minetest.get_connected_players
|
||||
local timer = 0
|
||||
|
||||
@ -17,3 +18,15 @@ minetest.register_globalstep(function(dtime)
|
||||
|
||||
timer = 0
|
||||
end)
|
||||
|
||||
|
||||
-- @see https://gitlab.com/4w/mtimer/issues/7
|
||||
if manual_gc == true then
|
||||
local gc_timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
gc_timer = gc_timer + dtime;
|
||||
if gc_timer < 10 then return end
|
||||
collectgarbage()
|
||||
gc_timer = 0
|
||||
end)
|
||||
end
|
||||
|
@ -1,5 +1,6 @@
|
||||
local m = mtimer
|
||||
|
||||
|
||||
-- Calculate HUD positions and offsets
|
||||
--
|
||||
-- Based on the given named position a table of positional tables is returned
|
||||
|
Loading…
Reference in New Issue
Block a user