mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
56b7786914
Fix RSS reporting on macOS > NOTE: This is a duplicate of #98164, which I closed because I borked my rustc fork Currently, `rustc_data_structures::profiling::get_resident_set_size()` always returns `None` on macOS. This is because macOS does not implement procfs used in the unix version of the function: ```rust ... else if #[cfg(unix)] { pub fn get_resident_set_size() -> Option<usize> { let field = 1; let contents = fs::read("/proc/self/statm").ok()?; let contents = String::from_utf8(contents).ok()?; let s = contents.split_whitespace().nth(field)?; let npages = s.parse::<usize>().ok()?; Some(npages * 4096) } ... ``` The proposed solution uses libproc, and more specifically `proc_pidinfo`, which has been available on macOS since 10.5 if the function signature inside libproc.h is to be believed: ```c int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); ``` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |