Linux check memory usage
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:
- Linux Find Out Virtual Memory PAGESIZE
- Linux performance tools to troubleshoot problem
- FreeBSD find out RAM size including total amount of free and used memory size
- Linux basic memory test for errors
- Linux display information about installed hardware
Discussion on This FAQ
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!
Tags: buffers, cpu activity, free memory, linux kernel, man page, memory size, memory usage, real time view, shell, system cpu, traps, vmstat


September 12th, 2007 at 8:12 am
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
November 30th, 2007 at 4:01 pm
Try:
ps aux | awk ‘{sum +=$4}; END {print sum}’
Bye!
December 6th, 2007 at 4:00 pm
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
February 1st, 2008 at 7:30 am
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
May 20th, 2008 at 4:15 am
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,
June 19th, 2008 (3 weeks ago) at 6:49 pm
is there any way/script to find out physcial memory usage exclusive of buffer/cache usage??