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 /volume-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 'volume-widget')
-rw-r--r-- | volume-widget/volume.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 4c44042..b689f6e 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -143,7 +143,9 @@ local function build_header_row(text) end local function rebuild_popup() + local reset_garbage_collector = 0 spawn.easy_async(LIST_DEVICES_CMD, function(stdout) + reset_garbage_collector = reset_garbage_collector + 1 local sinks, sources = utils.extract_sinks_and_sources(stdout) @@ -155,6 +157,11 @@ local function rebuild_popup() table.insert(rows, build_rows(sources, function() rebuild_popup() end, "source")) popup:setup(rows) + + if (reset_garbage_collector > 10) then + collectgarbage() + reset_garbage_collector = 0 + end end) end |