summaryrefslogtreecommitdiff
path: root/ram-widget
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-11-05 17:13:59 -0600
committerzachir <zachir@librem.one>2023-11-05 17:13:59 -0600
commit6ca46530b2c59d21ec83cb86a2dfc07f1e00f073 (patch)
treea5a8e85acf3b4564ac4c2d76fe5404cd282b855a /ram-widget
parent1b4e212fb60e54b2fdbf0d4584af68b7959cc24c (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 'ram-widget')
-rw-r--r--ram-widget/ram-widget.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua
index 867d28e..970c2d6 100644
--- a/ram-widget/ram-widget.lua
+++ b/ram-widget/ram-widget.lua
@@ -59,6 +59,8 @@ local function worker(user_args)
return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%'
end
+ local reset_garbage_collector = 0
+
watch('bash -c "LANGUAGE=en_US.UTF-8 free | grep -z Mem.*Swap.*"', timeout,
function(widget, stdout)
total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap =
@@ -77,6 +79,11 @@ local function worker(user_args)
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
}
end
+ reset_garbage_collector = reset_garbage_collector + 1
+ if (reset_garbage_collector > 9) then
+ collectgarbage()
+ reset_garbage_collector = 0
+ end
end,
ramgraph_widget
)