The Mem: total
figure is the total amount of RAM that can be used by applications. This is the total RAM installed on the system, minus:
- memory reserved by hardware devices (often video memory if the graphics card doesn't have its own RAM);
- memory used by the kernel itself.
That total includes:
free
: memory that is currently used for any purpose;
shared
: a concept that no longer exists. It's left in the output for backward compatibility (there are scripts that parse the output from free
). (On current systems you'll typically see nonzero values because shared
has been repurposed to show memory that's explicitly shared via a shared memory mechanism. On older systems, it included files mapped by more than one process and shareable memory that remained shared after fork()
.)
buffers
: memory that is backed by files, and that can be written out to disk if needed;
cache
: memory that is backed by files, and that can be reclaimed at any time (the difference with buffers
is that buffers must be saved to disk before they're reused, whereas cache consists of things that can be reloaded from disk);
used -buffers/cache
: memory used by applications (and not paged out to swap).
In a pinch, the system could run without buffers and cache, reserving RAM for applications and systematically performing disk reads and writes without any caching. The -/+ buffers/cache
figures indicate the amount of RAM used directly by applications (used
column) and the amount of RAM not used by applications (free
column).
Although this can vary a lot, a healthy system typically has around half its RAM devoted to applications and half devoted to buffers and cache. Unless you're running a dedicated file server, your system has more RAM than it needs for what you're currently doing. If the free - buffers/cache
figure was low, that would indicate a system that doesn't have enough RAM (contrary to a widespread belief, having a lot of memory devoted to buffers and cache is important for system performance, and trying to reserve more memory for applications would make 99.99% of systems slower).
The swap
line is straightforward, it shows the amount of swap that's in use (either by applications or for tmpfs
storage), and the amount that isn't.
A complete re-write of my previous post. Got a bit curious and checked out further.
In short: the reason for the difference is that openSUSE uses a patched version of top and free that adds some extra values to `cached'.
A) Standard version
top, free, htop, ...:
Usage is calculated by reading data from /proc/meminfo
:
E.g.:
#free:
Row Column | Corresponding /proc/meminfo entry
-----|--------|----------------------------------
Mem:
total : MemTotal
used : MemTotal - MemFree
free : MemFree
shared : MemShared
buffers : Buffers
cached : Cached
-----|--------|----------------------------------
-/+ buffers/cache:
used : (MemTotal - MemFree) - (Buffers + Cached)
free : MemFree + (Buffers + Cached)
#htop:
Used U* : ((MemTotal - MemFree) - (Buffers + Cached)) / 1024
*I'm using the name Used U
for memory used by User Mode.
Aka Used minus (Cached + Buffers).
So in reality same calculation is used.
htop
display the following in the memory meter:
[Used U % of total | Buffers % of total | Cached % of total ] UsedU MB
(MB is actually MiB.)
B) Patched version
The base for free
and top
on Debian, Fedora, openSuse is is procps-ng.
However, each flavour add their own patches that might, or migh not become
part of the main project.
Under openSUSE we find various additions to the top/free (procps) package.
The ones to take notice of here is some additional values used to represent
the cache value. (I did not include these in my previous post as my system
uses a "clean" procps.)
B.1) Additions
In /proc/meminfo we have Slab which is in-kernel data structure cache. As a sub category we find SReclaimable which is part of Slab that might be
reclaimed for other use both by Kernel and User Mode.
Further we have SwapCached which is memory that once was swapped out, is
swapped in but also is in the swap-file. Thus if one need to swap it out
again, this is already done.
Lastly there is NFS_Unstable which are pages sent to the server but not yet
committed to stable storage.
The following values are added to cache
in the openSUSE patched version:
SReclaimable
SwapCached
NFS_Unstable
(In addition there are some checks that total has to be greater then free,
used has to be greater then buffers + cache etc.)
B.2) Result
Looking at free, as a result the following values are the same:
total, used, free and buffers
.
The following are changed:
cached and "+/- buffers"
.
used = MemTotal - MemFree
old:
cached : Cached
+-/buffers-used: used - (Buffers + Cached)
+/-buffers-free: free + (Buffers + Cached)
patched:
cached : Cached + SReclaimable + SwapCached + NFS_Unstable
+/-buffers-used: used - (Buffers + Cached + SReclaimable +
SwapCached + NFS_Unstable)
+/-buffers-free: free + (Buffers + Cached + SReclaimable +
SwapCached + NFS_Unstable)
The same additions are done to top.
htop is unchanged and thus only aligning with older / or un-patched versions
of top / free.
Best Answer
I don't think it is possible, but, if you are up for building your own htop, not impossible. The code is at github and if you look at Meter.c you will see the logic they use to decide what to display.