Reputation: 57411
I have a server process running with pid 24257
and would like to know how much memory it is using (in order to estimate how much resources to allocate for the same process in Kubernetes). According to the man page for ps
(https://man7.org/linux/man-pages/man1/ps.1.html), this can be obtained with the %mem
output format specifier:
%mem %MEM ratio of the process's resident set size
to the physical memory on the machine,
expressed as a percentage. (alias pmem).
If I run this, I get
> ps -p 24257 -o %mem
%MEM
0.3
I'm not sure I understand this output, because I'm running the process on a MacBook Pro with 64 GB of memory, so I would expect the (Terminal) process to show up in the Activity Monitor as using ~19 GB of memory. However, the Terminal processes running are nowhere near that (they are at most ~900 Mb).
Is there a way I can get the memory usage as an absolute number (in Mb)? Or otherwise, how do I determine the "physical memory on the machine" used for this calculation?
Upvotes: 1
Views: 10151
Reputation: 57411
To convert Nate Eldredge's comments to an answer, firstly, the 0.3
output is a percentage, so 0.3% of 64 GB is 192 MB.
Secondly, the rss
output should give the resident set size:
rss RSS resident set size, the non-swapped physical
memory that a task has used (in kilobytes).
(alias rssize, rsz).
Running this command gives
> ps -p 24257 -o %mem,rss
%MEM RSS
0.3 209908
The output of ~21 Mb agrees pretty well with the estimate of ~19 Gb derived from the %MEM
output.
Upvotes: 5