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
atop
tracks historical metrics and is command line based.It's packaged in Debian/Ubuntu and Fedora.
https://www.atoptool.nl/index.php