Many times we need to know how much RAM or virtual memory a process is using. Suppose you are deploying a website on server and you want to configure Maxclient on apache configuration file and to set that first you need to know how much memory apache process is taking.
In this blog I will explain how we can check memory details on linux server.
In linux virtual memory is the sum of swap memory and RAM memory.
Virtual memory = swap memory + RAM memory
To check memory usage of a process we first need to know its id(pid), for that run following command in terminal
ps -A
It will show you all the running process on system, select pid of the process for which you want to check memory usage.
Now run following command (replace pid with actual process number)
cat /proc/pid/status
It will give output which include following terms(leave others), lets understand them:
VmSize: Virtual memory size.
VmRSS: Resident set size.(RAM memory)
(Vm stands for virtual memory)
Here VmSize=VmRSS + swap memory + shared memory (There may be another component about which I am not sure.)
So selected process is using VmRSS amount of RAM and in total VmSize.
If i am wrong anywhere then please correct me. Thanks.