diff options
author | zachir <zachir@librem.one> | 2023-11-05 17:13:59 -0600 |
---|---|---|
committer | zachir <zachir@librem.one> | 2023-11-05 17:13:59 -0600 |
commit | 6ca46530b2c59d21ec83cb86a2dfc07f1e00f073 (patch) | |
tree | a5a8e85acf3b4564ac4c2d76fe5404cd282b855a /mpdarc-widget | |
parent | 1b4e212fb60e54b2fdbf0d4584af68b7959cc24c (diff) |
Add reset_garbage_collector to sorta fix mem leaks
I added in a variable to force clearing the garbage collector more
often, so that the memory leaks involving awful.spawn.easy_async
wouldn't cause massive performance issues over time.
Diffstat (limited to 'mpdarc-widget')
-rw-r--r-- | mpdarc-widget/mpdarc.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/mpdarc-widget/mpdarc.lua b/mpdarc-widget/mpdarc.lua index a6a8e75..609efbf 100644 --- a/mpdarc-widget/mpdarc.lua +++ b/mpdarc-widget/mpdarc.lua @@ -87,13 +87,20 @@ mpdarc:connect_signal("button::press", function(_, _, _, button) elseif (button == 5) then awful.spawn(PREV_MPD_CMD, false) -- scroll down end + local reset_garbage_collector = 0 spawn.easy_async(GET_MPD_CMD, function(stdout, stderr, exitreason, exitcode) update_graphic(mpdarc, stdout, stderr, exitreason, exitcode) + reset_garbage_collector = reset_garbage_collector + 1 + if (reset_garbage_collector > 10) then + collectgarbage() + reset_garbage_collector = 0 + end end) end) local notification local function show_MPD_status() + local reset_garbage_collector spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) notification = naughty.notify { @@ -103,6 +110,11 @@ local function show_MPD_status() hover_timeout = 0.5, width = 600, } + reset_garbage_collector = reset_garbage_collector + 1 + if (reset_garbage_collector > 10) then + collectgarbage() + reset_garbage_collector = 0 + end end) end |