heim_process/process/
memory.rs

1use std::fmt;
2
3use heim_common::prelude::wrap;
4use heim_common::units::Information;
5
6use crate::sys;
7
8/// Memory information about the process.
9///
10/// See os-specific extensions also.
11pub struct Memory(sys::Memory);
12
13wrap!(Memory, sys::Memory);
14
15impl Memory {
16    /// Returns resident set size, amount of non-swapped physical memory used by the process.
17    pub fn rss(&self) -> Information {
18        self.as_ref().rss()
19    }
20
21    /// Returns virtual memory size, total amount of memory used by the process.
22    pub fn vms(&self) -> Information {
23        self.as_ref().vms()
24    }
25}
26
27impl fmt::Debug for Memory {
28    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29        f.debug_struct("Memory")
30            .field("rss", &self.rss())
31            .field("vms", &self.vms())
32            .finish()
33    }
34}