mirror of
https://gitlab.com/4w/mtimer.git
synced 2025-04-01 06:33:19 +02:00
try to circumvent Out Of Memory error (Win64)
See https://gitlab.com/4w/mtimer/issues/7
This commit is contained in:
3
init.lua
3
init.lua
@ -16,6 +16,9 @@ local S = minetest.get_translator('mtimer')
|
|||||||
mtimer = {
|
mtimer = {
|
||||||
translator = S,
|
translator = S,
|
||||||
dialog = {},
|
dialog = {},
|
||||||
|
config = {
|
||||||
|
manual_gc = minetest.settings:get_bool('mtimer_manual_gc', false)
|
||||||
|
},
|
||||||
meta = {
|
meta = {
|
||||||
visible = { key = 'mtimer:visible', default = 'true' },
|
visible = { key = 'mtimer:visible', default = 'true' },
|
||||||
position = { key = 'mtimer:position', default = 'bl' },
|
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 m = mtimer
|
||||||
local update_timer = m.update_timer
|
local update_timer = m.update_timer
|
||||||
|
local manual_gc = m.config.manual_gc
|
||||||
local connected_players = minetest.get_connected_players
|
local connected_players = minetest.get_connected_players
|
||||||
local timer = 0
|
local timer = 0
|
||||||
|
|
||||||
@ -17,3 +18,15 @@ minetest.register_globalstep(function(dtime)
|
|||||||
|
|
||||||
timer = 0
|
timer = 0
|
||||||
end)
|
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
|
local m = mtimer
|
||||||
|
|
||||||
|
|
||||||
-- Calculate HUD positions and offsets
|
-- Calculate HUD positions and offsets
|
||||||
--
|
--
|
||||||
-- Based on the given named position a table of positional tables is returned
|
-- Based on the given named position a table of positional tables is returned
|
||||||
|
Reference in New Issue
Block a user