How to check Memory Usage on Linux?

Various kinds of memory:

Physical Memory

It is the amount of DRAM currently in use.

Real Memory

It shows how much your applications are using system DRAM. It is roughly lower than Physical Memory. Linux Systems cache some disk data. Caching is the difference between Physical and Real Memory. The cached disk space will be made available to applications though on demand.

Swap Memory

Swap is additional space to your actual DRAM. This space is borrowed from disk space and once you application fill-out entire DRAM.

Virtual Memory

Virtual Memory == Swap Memory+ Physical Memory

How to see current Memory usage?

(A) Use free command:

$ free
             total       used       free     shared    buffers     cached
Mem:      16324640    9314120    7010520          0     433096    8066048
-/+ buffers/cache:     814976   15509664
Swap:      2047992          0    2047992

From Mem section (first line) above: shows memory usage including buffers/cache etc. Therefore free memory is shown as less. But remember, buffers/cache is temporary storage, a performance improvement trick of Linux. That memory is actually free and made available on demand.

We must look at the second line: -/+ buffers/cache section: used & free values – to find memory situation.

In this case,

  • 15509664K (15GB) Memory is free (This is what is really free memory that is available to you).
  • 814976K (814 MB) is used.
  • So, 15GB is actually a sum of free + buffers + cache from first line (7010520 + 433096 + 8066048).

Resulting data is in KB by default. Use free -m switch to see numbers in MB. free -sm 5 will refresh data every 5 seconds. watch free will do same without scrolling.

(B) use cat /proc/meminfo


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: