jeetsukumaran / Syrupy

System Resource Usage Profiler
http://jeetworks.org/programs/syrupy
GNU General Public License v3.0
194 stars 26 forks source link

RSS size should be used for sorting processes instead of VIRT, when doing poll_mem #21

Open sankouski-dzmitry opened 3 years ago

sankouski-dzmitry commented 3 years ago

In my vision, poll_mem is mostly used to determine, where your physical RAM leaks. VIRT memory doesn't show physical RAM occupation. To get process physical memory occupation, we should use RES memory.

To clearly illustrate, here is part of the log, showing chrome memory consumption:

PID         DATE      TIME      ELAPSED    CPU    MEM       RSS     VSIZE       CMD
12049   2021-09-08  17:16:57        00:01   24.0    0.4    135376  38186116  /opt/google/chrome/chrome --type=renderer --enable-automation --enable-logging --log-level=0 --remote-debugging-port=0 --test-type=webdriver --allow-pre-commit-input --field-trial-handle=9868597751347894126,1640417613699088952,131072 --disable-gpu-compositing --enable-blink-features=ShadowDOMV0 --lang=en-US --user-data-dir=/tmp/.com.google.Chrome.aFUGnx --disable-client-side-phishing-detection --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=7 --no-v8-untrusted-code-mitigations --shared-files=v8_context_snapshot_data:100

This chrome process was spawned by selenoid, when running UI autotests. As you can see, it mapped ~38GB of virtual memory (which is more that I have RAM on a server). On the other hand, it occupies only ~136MB of RAM. There's also other similar cases.

I think, a solution may be to give a choice for user, which memory to use for process sorting. Also default would be logical to change to RSS, IMHO.

mimmus commented 1 month ago

Change line 302: pinfoset = sorted(pinfoset, key=lambda v: int(v['rss']), reverse=True)[:top_mem]