cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:performance:memory.html



Memory on Linux Performance (free, sar, dstat, vmstat)

Check Memory

Ubuntu 20.04

root@ubuntu20:~# cat /proc/meminfo
MemTotal:        1004680 kB
MemFree:           78124 kB
MemAvailable:     558256 kB
Buffers:          217196 kB
Cached:           410028 kB
SwapCached:         5724 kB
Active:           350552 kB
Inactive:         349728 kB
Active(anon):      74496 kB
Inactive(anon):    72488 kB
Active(file):     276056 kB
Inactive(file):   277240 kB
Unevictable:       18468 kB
Mlocked:           18468 kB
SwapTotal:       2097148 kB
SwapFree:        1970172 kB
Dirty:              1324 kB
Writeback:             0 kB
AnonPages:         89260 kB
Mapped:           121588 kB
Shmem:             66048 kB
KReclaimable:     108468 kB
Slab:             172396 kB
SReclaimable:     108468 kB
SUnreclaim:        63928 kB
KernelStack:        2400 kB
PageTables:         3140 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2599488 kB
Committed_AS:     647488 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       20048 kB
VmallocChunk:          0 kB
Percpu:             1536 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 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:      561144 kB
DirectMap2M:      487424 kB
DirectMap1G:           0 kB
root@ubuntu20:~#


Linux Command for Memory

free

root@ubuntu20:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            981         186          74          64         719         544
Swap:          2047         124        1923
root@ubuntu20:~#


sar -r

root@ubuntu20:~# sar -r 1
Linux 5.4.0-65-generic (ubuntu20)       03/04/2021      _x86_64_        (2 CPU)

08:48:38 AM kbmemfree   kbavail kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
08:48:39 AM     76532    557816    127228     12.66    217480    410824    648660     20.91    352064    349816        68
08:48:40 AM     76500    557784    127260     12.67    217480    410824    648660     20.91    352064    349816        68
08:48:41 AM     76500    557784    127260     12.67    217480    410824    648660     20.91    352064    349816        68
08:48:42 AM     76468    557752    127292     12.67    217480    410824    648660     20.91    352064    349816        68
08:48:43 AM     76500    557784    127260     12.67    217480    410824    648660     20.91    352092    349816        52
08:48:44 AM     76500    557784    127260     12.67    217480    410824    648660     20.91    352092    349816        52
08:48:45 AM     76500    557784    127260     12.67    217480    410824    648660     20.91    352092    349816        52
^C
Average:        76500    557784    127260     12.67    217480    410824    648660     20.91    352076    349816        61
root@ubuntu20:~#


dstat

root@ubuntu20:~# dstat -t -gs --mem --vm --ipc
----system---- ---paging-- ----swap--- ------memory-usage----- -----virtual-memory---- --sysv-ipc-
     time     |  in   out | used  free| used  free  buff  cach|majpf minpf alloc  free|msg sem shm
04-03 08:49:38|  44B  131B| 125M 1923M| 258M  151M  214M  329M|   0    29    85    85 |  0   0   0
04-03 08:49:39|   0     0 | 125M 1923M| 258M  151M  214M  329M|   0     7    22    26 |  0   0   0
04-03 08:49:40|   0     0 | 125M 1923M| 258M  151M  214M  329M|   0     0    17    17 |  0   0   0
04-03 08:49:41|   0     0 | 125M 1923M| 258M  151M  214M  329M|   0     0    16     8 |  0   0   0
04-03 08:49:42|   0     0 | 125M 1923M| 258M  151M  214M  329M|   0     0    35    33 |  0   0   0
04-03 08:49:43|   0     0 | 125M 1923M| 258M  151M  214M  329M|   0     0    16    24 |  0   0   0
04-03 08:49:44|   0     0 | 125M 1923M| 258M  151M  214M  329M|   0     0    17    17 |  0   0   0
04-03 08:49:45|   0     0 | 125M 1923M| 258M  151M  214M  329M|   0     0    32    24 |  0   0   0
04-03 08:49:46|   0     0 | 125M 1923M| 258M  150M  215M  329M|   0     5    87    30 |  0   0   0^C


vmstat

root@ubuntu20:~# vmstat -taw 1
procs -----------------------memory---------------------- ---swap-- -----io---- -system-- --------cpu-------- -----timestamp-----
 r  b         swpd         free        inact       active   si   so    bi    bo   in   cs  us  sy  id  wa  st                 JST
 0  0       127744       157036       260416       372668    0    0    12    14    3    1   0   0 100   0   0 2021-03-04 08:50:42
 0  0       127744       157044       260428       372888    0    0     4    28  170  145   1   0  99   0   0 2021-03-04 08:50:43
 0  0       127744       154616       261928       372924    0    0    16     0  438  270   2   1  97   0   0 2021-03-04 08:50:44
 0  0       127744       156256       260412       372924    0    0     0     0  907  147   0   0 100   0   0 2021-03-04 08:50:45
 0  0       127744       154988       260696       373016    0    0   368     0  569  297   3   1  97   0   0 2021-03-04 08:50:46
 0  0       127744       154988       260696       373016    0    0     0     0  110  101   0   0 100   0   0 2021-03-04 08:50:47
 0  0       127744       154988       260696       373016    0    0     0   116  151  129   0   0 100   1   0 2021-03-04 08:50:48
^C
root@ubuntu20:~#




Related Pages




os/linux/performance/memory.html.txt ยท Last modified: 2021/03/04 by admin

Page Tools