System Administration - Uslites
How to Check Memory Usage Per Process
on Linux
6 months agoby Shabir Shovon
‘These days, a computer can run many programs at once. The CPU has no problem handling all
these programs because CPUs has multiple cores to handle mutt-tasking,
Each of these programs runs as one or more processes. Every process allocates some amount of
RAM or memory for itself. It is essential for the process to function correctly. If a process fails to
allocate enough RAM or memory, then the process can't be created and the program won't be able
to start,
So, one of the basic task you do on your computer is to check how much memory or RAM
(Random Access Memory) each of the process is using. Because, RAM or memory of your
computer is limited.
Imagine a case, where you want to run some program and it fails because you don't have enough
memory. May be some of the processes are using a lot of memory that you don’t need right now.
You can kill or stop these processes to free up RAM or memory, so that you can start your
important programs.
In this article, | will show you how to check memory usage of each of the processes running on
your Linux machine. | will be using Debian 9 Stretch for all the demonstration in this article. But it
should work on any modern Linux distributions. Let's get started.Checking Memory Usage Using ps Command:
You can use the ps command to check memory usage of all the processes on Linux. There is one
problem with this procedure. ps don't really show you how much memory a process uses in KB or
MB format, but it will show you how much memory is being used in percentage.
You can check memory usage (in percentage) of all the process running on your Linux operating
system with the following command:
$ ps -o pid,user,%mem, command ax
ile Edit View Search Terminal Help
{As you can see, all the processes with memory usage in percentage is listed in descending order
(The processes using most of the memory is listed first),You can check memory of a process or a set of processes in human readable form:
kilobytes) with pmap command. All you need is the PID of the processes you want to check
memory usage of.
Let's say, you want to check how much memory the process with PID 917 is using. To do that,
run pmap as follows:
$ sudo pmap 917