LKBEN11095: Howto find mem information in linux


This article has not been checked!

LKB | Created: 02/04/2020 | Version: 0 | Language: EN | Rating: 0 | Outdated: False | Marked for deletion: False

Author: Wim Peeters - Keskon GmbH & Co. KG


Symptom

You want to find out how much memory is in use

Cause

none

Solution

There are several ways to find out how much memory your system is using. Apart from litte information tools like xosview or Superkaramba sysinfo, you have the following command line tools.

- top
- /proc/meminfo
- free

Top will not just deliver memory information. A normal top output looks like:

top - 20:45:36 up 20 min,  1 user,  load average: 0.38, 0.40, 0.35
Tasks: 133 total,   1 running, 132 sleeping,   0 stopped,   0 zombie
Cpu(s): 16.2% us,  3.0% sy,  2.0% ni, 69.8% id,  8.9% wa,  0.1% hi,  0.0% si
Mem:    905344k total,   825044k used,    80300k free,   110936k buffers
Swap:  1124508k total,        0k used,  1124508k free,   516980k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5146 root      15   0  153m  20m 3132 S 11.9  2.3   1:05.79 Xorg
    1 root      16   0  1568  532  460 S  0.0  0.1   0:01.03 init
    2 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    4 root      10  -5     0    0    0 S  0.0  0.0   0:00.08 events/0
    5 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 khelper
    6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
    8 root      10  -5     0    0    0 S  0.0  0.0   0:00.14 kblockd/0
    9 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid
  118 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pdflush
  119 root      15   0     0    0    0 S  0.0  0.0   0:00.03 pdflush
  121 root      18  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0
  120 root      15   0     0    0    0 S  0.0  0.0   0:00.01 kswapd0
  708 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 kseriod
 1800 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khubd
 1815 root      15   0     0    0    0 S  0.0  0.0   0:00.00 khpsbpkt
 1835 root      15   0     0    0    0 S  0.0  0.0   0:00.00 knodemgrd_0
 1904 root      15   0     0    0    0 S  0.0  0.0   0:00.10 kjournald
...

At the 4th line you see the memory information.

You can also use the /proc/meminfo information and show it at the commandline:

cat /proc/meminfo
MemTotal:       905344 kB
MemFree:         80864 kB
Buffers:        111164 kB
Cached:         516912 kB
SwapCached:          0 kB
Active:         422456 kB
Inactive:       327316 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       905344 kB
LowFree:         80864 kB
SwapTotal:     1124508 kB
SwapFree:      1124508 kB
Dirty:             184 kB
Writeback:           0 kB
Mapped:         183416 kB
Slab:            64332 kB
CommitLimit:   1577180 kB
Committed_AS:   357872 kB
PageTables:       2400 kB
VmallocTotal:   114680 kB
VmallocUsed:      5832 kB
VmallocChunk:   108540 kB

And last but not least you can use the command free.

free
             total       used       free     shared    buffers     cached
Mem:        905344     826172      79172          0     111316     517252
-/+ buffers/cache:     197604     707740
Swap:      1124508          0    1124508

About the Author

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux in different European countries and different European languages. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform where he is one of the most important contributors and the main developer.

Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!