Linux Display Memory: Processes Consuming Most Memory in Linux and How to Manage them with Commands

Introduction to Memory Management
The memory on a computer is one of the most demanded resources from any application. All applications need memory to run, some more than others. Even though memory is dirt cheap these days, it always helps to clean the list of running processes and check if any applications are utilizing more memory than required. You can then quit/restart these applications to free up wasted memory.
The commands used in this article will be most useful when you have system-wide privileges. This can be in the form of a root password or relevant privileges with the sudo command.
Top
The “top” command is one of the most important utilities available for any user in Linux. It is just like the Task Manager in Windows and displays a list of the running tasks and various details about each application. The output is automatically updated often. The output of top contains the following fields:
PID, User, PR, NI, VIRT, RES, SHR, S, %CPU, %MEM, TIME+ and COMMAND.
While some of the fields are not important for us, the column you should be paying attention to is %MEM. This column displays the percentage of total memory that the application is using. For example, if the Xorg command is shown with 10% of memory on a computer running 2GB of total memory (physical + swap memory), then it is using around 200MB of memory.
vmstat
The “vmstat” command shows summary information about memory, processes, interrupts, paging and block I/O information. We’re only interested in the information about memory. Typing the command as “vmstat -S M” will show the memory sizes in MB form, which is easier to read and understand. The Free column shows how much free memory we have. The “buff” column shows the amount of buffered memory, and “cache” shows the amount of cached information in the memory.
Since this command gives a barebones-style output, using commands like top is recommended for a better understanding of the memory usage on your Linux computer.
free
The “free” command shows a nicely summarized table containing information about the memory on your computer. Different columns are given to show information about Total memory, Used memory and Free memory. Typing the command as “free -m -t” shows you the information in MB units and a row at the bottom giving the Total amount of memory of each column.
Check out the picture to understand the output of the free command.
ps
The “ps” command is the most useful command for any system administrator or user. It displays a list of running processes on the computer. The output is quite similar to the top command, but with the ability to pick and choose what type of information is included in the output. Typing the command as “ps aux” shows a list of all the running processes for all users on the system. The information given by the ps command is similar to the information given by the top command and therefore, if you can understand the output of one, you can easily understand the output of the other command.
Check out the picture of the ps command in action.
Final Words
With these awesome tools in hand, you should easily be able to locate rogue applications which are using a lot of memory on your system. Once you have the PID of the processes, you can simply close them using their respective interfaces or through the command line by typing the command “kill ”, where is replaced by the PID of the application in question.