Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/columns/os_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -149,6 +151,7 @@ pub enum ConfigColumnKind {
Username,
VmRss,
VmSize,
VmTotal,
WriteBytes,
}

Expand Down Expand Up @@ -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)),
}
}
Expand Down Expand Up @@ -315,6 +319,10 @@ pub static KIND_LIST: Lazy<BTreeMap<ConfigColumnKind, (&'static str, &'static st
),
(ConfigColumnKind::VmRss, ("VmRss", "Resident set size")),
(ConfigColumnKind::VmSize, ("VmSize", "Physical page size")),
(
ConfigColumnKind::VmTotal,
("VmTotal", "Total footprint size"),
),
(
ConfigColumnKind::WriteBytes,
("WriteBytes", "Write bytes to storage"),
Expand Down
83 changes: 83 additions & 0 deletions src/columns/vm_total.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
use crate::process::ProcessInfo;
use crate::util::bytify;
use crate::{column_default, Column};
use std::cmp;
use std::collections::HashMap;

pub struct VmTotal {
header: String,
unit: String,
fmt_contents: HashMap<i32, String>,
raw_contents: HashMap<i32, u64>,
width: usize,
}

impl VmTotal {
pub fn new(header: Option<String>) -> 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);
}