Get RSS without forking on MacOS X or Windows
skull-squadron opened this issue · comments
🏴☠️ commented
These might be helpful:
- http://nadeausoftware.com/articles/2012/07/c_c_tip_how_get_process_resident_set_size_physical_memory_use (see getCurrentRSS)
- http://www.opensource.apple.com/source/adv_cmds/adv_cmds-147/ps/
- http://www.opensource.apple.com/tarballs/adv_cmds/adv_cmds-147.tar.gz
- http://cpansearch.perl.org/src/JSWARTZ/Proc-ProcessTable-0.46/os/
🏴☠️ commented
OSX: It appears ps
is signed or whitelisted to allow some syscalls, possibly including task_for_pid
Simple test:
Regular ps
$ ps -opid,rss
PID RSS
50351 5040
81222 6028
22750 5008
24728 540
24729 540
56332 2600
52229 4864
Copy of ps
$ cp /bin/ps ~/bin_ps && ~/bin_ps -opid,rss && rm ~/bin_ps
PID RSS
50351 0
81222 0
22750 0
24728 0
24729 0
56332 0
52229 0
56699 548
Kazuki Ohta commented
pull request are welcomed. the current committers assume that this gem is used at Linux on production environment.
🏴☠️ commented
TL;DR: Reading RSS from another pid is likely not possible on OSX.