Linux

How to check memory (RAM) usage in Linux?

Once we face some memory issues in linux server, usually first of all check disk space. It might be the case that some applications stuffed it with log files or some other content. Here are few instructions how to do that – How to identify which files take most of the disk space in Linux?.

However disk space might be totally ok and you still experience exceptions which are saying something about memory… In such a case, check RAM usage as well. Maybe it is not configured properly, some issues with swapping or something other which results into deficiency of RAM. Here is how to check RAM on your linux machine:

$ free -m

Here you can find total, used and free amount of memory. Numbers are displayed in Mbytes. Size and usage of Swap also is there.

Once you identify that there is a memory deficiency, can try to identify which processes consumes most of it:

ps aux –sort -rss

Here in column RSS you see memory usage in Kbytes. Also you see command which starts a process and process ID (PID), thus can take control of it by restarting or going into deeper investigation why it takes so much memory.

If it is not a production environment or it is just not critical, can try to kill that process while you know its PID, i.e.:

$ kill 22207

About Danas Tarnauskas