Skip to content

Instantly share code, notes, and snippets.

@Beherith
Created January 17, 2024 13:43
Show Gist options
  • Save Beherith/c22d5c3e44274149a92a593a1a2ffb30 to your computer and use it in GitHub Desktop.
Save Beherith/c22d5c3e44274149a92a593a1a2ffb30 to your computer and use it in GitHub Desktop.
Garbage Colector
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