Created
January 17, 2024 13:43
-
-
Save Beherith/c22d5c3e44274149a92a593a1a2ffb30 to your computer and use it in GitHub Desktop.
Garbage Colector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function widget:GetInfo() | |
return { | |
name = "Garbage Collector", | |
desc = "Takes out the trash if there is way too much of it", | |
author = "Beherith", | |
date = "20240117", | |
license = "GNU GPL, v2 or later", | |
layer = 0, | |
enabled = true, | |
} | |
end | |
local interval = 100 | |
function widget:Update() | |
if Spring.GetDrawFrame() % interval == 0 then | |
local kbytes = collectgarbage("count") | |
if kbytes > 500000 then | |
collectgarbage("collect") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment