0

From the author of htops answer https://stackoverflow.com/questions/41224738/how-to-calculate-system-memory-usage-from-proc-meminfo-like-htop/41251290#41251290

I got to know that the total memory in htop is calculated from /proc/meminfo. I think I could crosscheck this in code as well and it checks out. However compared to memory bar in htop. I see a major difference in the memory values shown in /proc/meminfo.

In my /proc/meminfo the memory consumption reads

MemTotal:       4144807288 kB
MemFree:        3513532764 kB
MemAvailable:   3936769368 kB
Buffers:         1119392 kB

So the Total used memory , which I think represented by the memory bar should be MemTotal-MemFree in GBs which should be (4144807288-3513532764)/1024^2=602Gb as far as I understand. However for me this value shows almost 180Gb. Could anyone explain how the values in /proc/meminfo and one in htop would become different. enter image description here

1 Answer 1

1

My guess why the values differ is the following:

htop "180G" value does not include system buffers and other memory used by operating system, while /proc/meminfo reports it as allocated

Digging into https://github.com/htop-dev/htop/blob/541c17c975bc8a4f1f243e568006b0e26ae52c47/linux/LinuxMachine.c#L130 can help to understand how htop values are calculated

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .