Score:1

How to calculate used memory of 'free' command

bf flag

How to calculate used memory?
In below case, 15784520(RSS memory of 'top' command) + ? = 16031516(used memory of 'free' command)

root@host:~# free -w
              total        used        free      shared     buffers       cache   available
Mem:       82376116    16031516    30084440       16780        2328    36257832    65487292
Swap:             0           0           0

root@host:~#  ps aux | awk '{sum +=$5}END{print sum}'
111284060

root@host:~#  ps aux | awk '{sum +=$6}END{print sum}'
15784520

root@host:~#  cat /proc/meminfo
MemTotal:       82376116 kB
MemFree:        30077632 kB
MemAvailable:   65480784 kB
Buffers:            2328 kB
Cached:         30545640 kB
SwapCached:            0 kB
Active:         24199852 kB
Inactive:       19097572 kB
Active(anon):   12741724 kB
Inactive(anon):     7588 kB
Active(file):   11458128 kB
Inactive(file): 19089984 kB
Unevictable:         160 kB
Mlocked:             160 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               312 kB
Writeback:             0 kB
AnonPages:      12741616 kB
Mapped:          1301004 kB
Shmem:             16780 kB
KReclaimable:    5712492 kB
Slab:            7411268 kB
SReclaimable:    5712492 kB
SUnreclaim:      1698776 kB
KernelStack:       40496 kB
PageTables:        51424 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    41188056 kB
Committed_AS:   26394284 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      328328 kB
VmallocChunk:          0 kB
Percpu:           106656 kB
HardwareCorrupted:     0 kB
AnonHugePages:      4096 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:     3090304 kB
DirectMap2M:    73455616 kB
DirectMap1G:     9437184 kB
Artur Meinild avatar
vn flag
Nice use of `awk` to sum up columns.
Score:2
vn flag

15.7 GB is used by processes, and 16.0 GB used in total.

This means that probably around 300 MB is used by the kernel "behind-the-scenes", just by itself or for filesystem operations.

This is not in any way unnatural, and just the way Ubuntu/Linux (or any other OS for that matter) works.

Also see this question.

M.Ozawa avatar
bf flag
Thank you for your answer.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.