I have a htpc/server-ish ubuntu box running at home with kodi (xbmc) and some other webservices.
I noticed kodi was laggish and ssh'ed into the box to see what was going on. I saw this htop output:
This is the output of free -m
richard@RMD-HTPC:~$ free -m
total used free shared buffers cached
Mem: 7642 7505 137 152 196 1296
-/+ buffers/cache: 6012 1630
Swap: 1905 10 1895
How come the ram usage is at 6000 of 7600mb in the screenshot
at 7505 in free
But when I add up all the percentages of the unique processes in htop I only go to about 22-25% ? Should it not be much higher?
Best Answer
It is because
htop
is counting buffers and cached memory as free memory, because it can actually can be seen this way.There is no "cost" in having some cached data in memory, so the kernel keep stuff there just in case it needs afterwards.
For instance, suppose you have watched a video of about 500mb, after you close the video, the kernel may decide to keep it in memory instead of cleaning that part, just in case you need that video again so it doesn't need to load it again from your slow HDD. But that 500mb can be considered free, because as soon as you need memory for something else, the kernel will be able to use that memory right away.
It is not the case when that memory is being used by a running program, because that program is using that memory right now.
If you subtract from the
used
memory thebuffers
andcached
values, you will get the value displayed byhtop
.Now about that percentage you said, it depends on how you have summed up.