Closed xfzv closed 1 year ago
Nevermind, I figured how to add shared memory. Source
function mem.update()
mem_now = {}
for line in lines("/proc/meminfo") do
for k, v in gmatch(line, "([%a]+):[%s]+([%d]+).+") do
if k == "MemTotal" then
mem_now.total = floor(v / 1024 + 0.5)
elseif k == "MemFree" then
mem_now.free = floor(v / 1024 + 0.5)
elseif k == "Buffers" then
mem_now.buf = floor(v / 1024 + 0.5)
elseif k == "Cached" then
mem_now.cache = floor(v / 1024 + 0.5)
elseif k == "SwapTotal" then
mem_now.swap = floor(v / 1024 + 0.5)
elseif k == "SwapFree" then
mem_now.swapf = floor(v / 1024 + 0.5)
+ elseif k == "Shmem" then
+ mem_now.share = floor(v / 1024 + 0.5)
elseif k == "SReclaimable" then
mem_now.srec = floor(v / 1024 + 0.5)
end
end
end
- mem_now.used = mem_now.total - mem_now.free - mem_now.buf - mem_now.cache - mem_now.srec
+ mem_now.used = mem_now.total + mem_now.share - mem_now.free - mem_now.buf - mem_now.cache - mem_now.srec
Today I launched two virtual machines with respectively 4 and 6GB of allocated shared memory. I was a bit surprised to see the low RAM percentage usage in my awesome wibar after a while.
It seems that
mem.lua
doesn't take into account theShmem
value from/proc/meminfo
, like other tools such as top or htop:https://github.com/lcpz/lain/blob/88f5a8abd2649b348ffec433a24a263b37f122c0/widget/mem.lua#L38
On the other hand, Bottom does and gives me a more realistic RAM usage (huge difference actually, currently
mem.lua
reports 20% versus 35% with bottom).I assume this is done on purpose, although it feels quite inaccurate to me.
Any chance this could change? or could someone suggest what modifications I should do to achieve that?
Thanks.