From 0ec6ea407d8938f281df1ac6b4fbdf7abc249984 Mon Sep 17 00:00:00 2001 From: Emily M Klassen Date: Wed, 2 Jul 2025 19:40:51 -0700 Subject: [PATCH 1/2] add VmTotal column for macos use actual macos memory usage from libproc pid_rusage --- src/columns/os_macos.rs | 8 ++++ src/columns/vm_total.rs | 83 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/columns/vm_total.rs diff --git a/src/columns/os_macos.rs b/src/columns/os_macos.rs index 9c2ebc037..af45435f1 100644 --- a/src/columns/os_macos.rs +++ b/src/columns/os_macos.rs @@ -43,6 +43,7 @@ pub mod user_real; pub mod user_saved; pub mod vm_rss; pub mod vm_size; +pub mod vm_total; pub mod write_bytes; pub use self::arch::Arch; @@ -90,6 +91,7 @@ pub use self::user_real::UserReal; pub use self::user_saved::UserSaved; pub use self::vm_rss::VmRss; pub use self::vm_size::VmSize; +pub use self::vm_total::VmTotal; pub use self::write_bytes::WriteBytes; use crate::column::Column; @@ -149,6 +151,7 @@ pub enum ConfigColumnKind { Username, VmRss, VmSize, + VmTotal, WriteBytes, } @@ -214,6 +217,7 @@ pub fn gen_column( ConfigColumnKind::Username => Box::new(User::new(header, abbr_sid)), ConfigColumnKind::VmRss => Box::new(VmRss::new(header)), ConfigColumnKind::VmSize => Box::new(VmSize::new(header)), + ConfigColumnKind::VmTotal => Box::new(VmTotal::new(header)), ConfigColumnKind::WriteBytes => Box::new(WriteBytes::new(header)), } } @@ -315,6 +319,10 @@ pub static KIND_LIST: Lazy, + raw_contents: HashMap, + width: usize, +} + +impl VmTotal { + pub fn new(header: Option) -> Self { + let header = header.unwrap_or_else(|| String::from("VmTotal")); + let unit = String::from("[bytes]"); + Self { + fmt_contents: HashMap::new(), + raw_contents: HashMap::new(), + width: 0, + header, + unit, + } + } +} + +#[cfg(any(target_os = "linux", target_os = "android"))] +impl Column for VmTotal { + fn add(&mut self, proc: &ProcessInfo) { + use procfs::WithCurrentSystemInfo; + let raw_content = proc.curr_proc.stat().rss_bytes().get(); + let fmt_content = bytify(raw_content); + + self.fmt_contents.insert(proc.pid, fmt_content); + self.raw_contents.insert(proc.pid, raw_content); + } + + column_default!(u64, true); +} + +#[cfg(target_os = "macos")] +impl Column for VmTotal { + fn add(&mut self, proc: &ProcessInfo) { + let raw_content = match &proc.curr_res { + Some(mem) => mem.ri_phys_footprint, + None => proc.curr_task.ptinfo.pti_resident_size, + }; + let fmt_content = bytify(raw_content); + + self.fmt_contents.insert(proc.pid, fmt_content); + self.raw_contents.insert(proc.pid, raw_content); + } + + column_default!(u64, true); +} + +#[cfg(target_os = "windows")] +impl Column for VmTotal { + fn add(&mut self, proc: &ProcessInfo) { + let raw_content = proc.memory_info.working_set_size; + let fmt_content = bytify(raw_content); + + self.fmt_contents.insert(proc.pid, fmt_content); + self.raw_contents.insert(proc.pid, raw_content); + } + + column_default!(u64, true); +} + +#[cfg(target_os = "freebsd")] +impl Column for VmTotal { + fn add(&mut self, proc: &ProcessInfo) { + let raw_content = (proc.curr_proc.info.rssize as u64).saturating_mul(4096); + let fmt_content = bytify(raw_content); + + self.fmt_contents.insert(proc.pid, fmt_content); + self.raw_contents.insert(proc.pid, raw_content); + } + + column_default!(u64, true); +} From 06c058feb0311b3ad67adae9e754a09ea2589360 Mon Sep 17 00:00:00 2001 From: Emily M Klassen Date: Tue, 6 Jan 2026 10:39:51 -0800 Subject: [PATCH 2/2] update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 885bda24c..c110b1d19 100644 --- a/README.md +++ b/README.md @@ -508,11 +508,14 @@ The first `[[columns]]` is shown at left side, and the last is shown at right si | VmSize | vsz | Physical page size | o | o | o | o | | VmStack | -not supported- | Stack size | o | | | o | | VmSwap | -not supported- | Swapped-out virtual memory size | o | | o | | +| VmTotal | -not supported- | Total virtual memory size | *[^*] | o | *[^*] | *[^*] | | VoluntaryContextSw | -not supported- | Voluntary context switch count | o | | | o | | Wchan | wchan | Process sleeping kernel function | o | | | o | | WorkDir | -not supported- | Current working directory | o | | | | | WriteByte | -not supported- | Write bytes to storage | o | o | o | o | +[^*]: Alias for VmRss on these platforms + #### `style` list - BrightBlack