Linux Commands : Is Linux Eating My RAM?

By Yashwant
Feb 27th, 2014
Is Linux Eating My RAM?

Is Linux Eating My RAM?

I explained top command in my previous post regarding improving performance of linux systems. When we talk about performance, first thing came to our mind is RAM usage. In more RAM is free then we say we can run more applications and machine is faster. On Linux boxes RAM usage is stored in meminfo file in proc folder.

$ cat proc/meminfo

There are utilities like vmstat which help us in understanding data from meminfo in a much better way.

$ vmstat -s -S M

When you are heavily using your machine, above statement gives you a fair idea of how much RAM is used and you can check with output of top command to find which processes are using RAM. Though sometimes there are scenarios when we are not running many applications still used RAM is quite high. Now, if applications are not running then where is my RAM? Is Linux eating my RAM or some unnecessary background processes are running? I searched for it and found that it’s not an unusual behavior. What I misunderstood was the exact meaning of terms “used” and “free” in case of RAM.

Basically if there is RAM available then Linux tries to use it for caching. As we all know reading and writing from RAM is much faster as compared to hard disk. So caching improves performance. Memory used by caching can be freed anytime instantly if any application needs it. So this part of memory is both used and free and it sometimes creates confusion. So how to avoid this confusion? Use free –m command

# free -m

total used free shared buffers cached
 Mem: 7917 7809 108 0 164 3900
 -/+ buffers/cache: 3744 4173
 Swap: 2047 167 1879

First line shows amount of RAM which is either used for Applications or for Caching. Second line clears all the doubts and tells us exact amount used by applications. So next time if you see less free RAM, don’t panic, be happy that Linux is trying to use resources in a much efficient way then leaving them idle.

If you want to read more details about the same check this link.

About the Author

- An avid reader and a big time comics fan. A software engineer by profession who loves writing code and make things work.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

facebook comments: