Use RSS or VMS to track memory?
See original GitHub issueWe recently added mechanisms to track a worker’s memory use in order to slow down or terminate that worker to avoid out-of-memory errors. When tracking memory we can look at either RSS or VMS memory use.
[1]: import psutil
In [2]: psutil.Process().memory_info()
Out[2]: pmem(rss=34463744, vms=289349632, shared=5316608, text=4096, lib=0, data=179593216, dirty=0)
Which should we be tracking? What do job schedulers track?
VMS is a bit unfortunate in that it includes 300MB of Python and 600MB including numpy, pandas, etc. which are sometimes just forked from the main process.
RSS is a bit unfortunate in that it seems not to include data allocated by NumPy.
In [3]: import numpy as np
In [4]: psutil.Process().memory_info()
Out[4]: pmem(rss=43642880, vms=358273024, shared=8069120, text=4096, lib=0, data=186109952, dirty=0)
In [5]: x = np.empty(int(1e9), dtype='u1')
In [6]: psutil.Process().memory_info()
Out[6]: pmem(rss=43642880, vms=1358274560, shared=8069120, text=4096, lib=0, data=1186111488, dirty=0)
Given this I think we have to use VMS. I’m not very familiar with what is commonly tracked by job schedulers that might kill a job though, so I thought I’d put this up here for general comment.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Difference Between Resident Set Size and Virtual Memory Size
RSS is not an accurate measure of the total memory processes are consuming, because it does not include memory consumed by libraries that...
Read more >Accurately measuring memory usage - Passenger Library
You may have seen that those tools present various memory usage metrics, such as "RSS" and "VMSize". Different metrics represent different things, but...
Read more >Memory RSS vs VSZ
RSS is the Resident Set Size and is used to show how much memory is allocated to that process and is in RAM....
Read more >Memory_working_set vs Memory_rss in Kubernetes ... - Medium
Which one we should monitor, and which one causes OOMkill if we applied ... cAdvisor gathers those numbers and uses them to calculate...
Read more >How to check memory utilization by a process in Linux
In Linux, process memory utilization is measured by two values, VSZ and RSS (both measured in bytes). RSS stands for Resident Set Size...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK, so my case of not seeing RSS rise was more a function of my use of empty (or zeros it turns out) rather than a real use case.
This may be the explanation:
From: https://landley.net/writing/memory-faq.txt