About Linux FAQ

Browse More FAQs:

Linux check memory usage

Posted by Vivek Gite [Last updated: December 7, 2007]

Linux comes with different command to check memory usage. free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel.

vmstat command reports information about processes, memory, paging, block IO, traps, and cpu activity.

Then you can use top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.

free command

Display free memory size in MB:

$ free -mOutput:

             total       used       free     shared    buffers     cached
Mem:           750        625        125          0         35        335
-/+ buffers/cache:        254        496
Swap:          956          0        956

Displays a line containing the totals memory in MB:
$ free -t -m
Output:

       total       used       free     shared    buffers     cached
Mem:           750        625        125          0         35        335
-/+ buffers/cache:        253        496
Swap:          956          0        956
Total:        1707        625       1082

vmstat command

Type vmstat command at shell prompt:
$ vmstatOutput:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
1  0      0 131620  35432 341496    0    0    42    82  737  1364 15  3 81  1

top command

Type top command at shell prompt:
$ topTo exit from top command type q key.

Read man page of free, vmstat, top command for complete information.

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Other Helpful FAQs:

Discussion on This FAQ

  1. suresh Says:

    Hi ,

    I need a unix command to get the total memory usage percentage.so that i can call this command from java.The output of the command should only be the percentage of memory utilization.

    thanks
    Suresh

  2. Matt Says:

    Try:

    ps aux | awk ‘{sum +=$4}; END {print sum}’

    Bye!

  3. Michael Says:

    Using the command free, vmstat, top all shows it uses almost 100% of the memory. But if I use the system monitor, it will show only less than 10%.

    I am using CentOS 5. can anyone explain why the free, vmstat, top all displaying wrong information? Thanks.

    $ free -m
    total used free shared buffers cached
    Mem: 3792 3638 154 0 128 3231
    -/+ buffers/cache: 277 3515
    Swap: 1983 0 1983
    $ vmstat
    procs ———–memory———- —swap– —–io—- –system– —–cpu——
    r b swpd free buff cache si so bi bo in cs us sy id wa st
    0 0 108 158380 131948 3309388 0 0 106 75 203 180 0 0 98 1 0

  4. Atahan Says:

    Actualy memory is not used by application, but it is used for disk caching.
    If memory is not fully utilized by kernel than it is wasted, by keeping data in cache when an application needs data again it can be provided faster.
    If you want to see the memory from the perspective of application you should look at +- buffers/cache line, the free column of this line shows you the memory that can be used for applications.

    In the case below my application using 2GB of memory.

    # free -m
    total used free shared buffers cached
    Mem: 7973 7323 650 0 128 5152
    -/+ buffers/cache: 2042 5931
    Swap: 8189 40 8149

  5. Ohm Says:

    Hi ,

    I take care 2000 PCs that using Redhat 7.3. I’m finding the command to create script file to check RAMBus of the PCs. Could you please help to recommend the appropriate one ?

    Thanks.

    Regard,

  6. pudhiyavan Says:

    is there any way/script to find out physcial memory usage exclusive of buffer/cache usage??

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.