heim_process/os/windows/
memory.rs

1/// Windows-specific extension to process [Memory] information.
2///
3/// Information here is provided by the [PROCESS_MEMORY_COUNTERS_EX] struct,
4/// see its documentation for details.
5///
6/// [Memory]: ../../struct.Memory.html
7/// [PROCESS_MEMORY_COUNTERS_EX]: https://docs.microsoft.com/en-us/windows/win32/api/psapi/ns-psapi-process_memory_counters_ex
8pub trait MemoryExt {
9    /// Returns the number of page faults.
10    fn page_faults(&self) -> u32;
11
12    /// Returns the the peak working set size.
13    fn peak_working_set_size(&self) -> usize;
14
15    /// Returns the current working set size.
16    fn working_set_size(&self) -> usize;
17
18    /// Returns the peak paged pool usage.
19    fn quota_peak_paged_pool_usage(&self) -> usize;
20
21    /// Returns the current paged pool usage.
22    fn quota_paged_pool_usage(&self) -> usize;
23
24    /// Returns the peak nonpaged pool usage.
25    fn quota_peak_non_paged_pool_usage(&self) -> usize;
26
27    /// Returns the current nonpaged pool usage.
28    fn quota_non_paged_pool_usage(&self) -> usize;
29
30    /// Returns the *Commit Charge* value in bytes.
31    ///
32    /// Commit Charge is the total amount of memory
33    /// that the memory manager has committed for a running process.
34    fn pagefile_usage(&self) -> usize;
35
36    /// Returns the peak value in bytes of the *Commit Charge*
37    /// during the lifetime of this process.
38    fn peak_pagefile_usage(&self) -> usize;
39
40    /// Same as [`pagefile_usage`](#tymethod.pagefile_usage).
41    ///
42    /// The *Commit Charge* value in bytes for this process.
43    /// Commit Charge is the total amount of memory
44    /// that the memory manager has committed for a running process.
45    fn private_usage(&self) -> usize;
46}
47
48#[cfg(target_os = "windows")]
49impl MemoryExt for crate::Memory {
50    fn page_faults(&self) -> u32 {
51        self.as_ref().page_faults()
52    }
53
54    fn peak_working_set_size(&self) -> usize {
55        self.as_ref().peak_working_set_size()
56    }
57
58    fn working_set_size(&self) -> usize {
59        self.as_ref().working_set_size()
60    }
61
62    fn quota_peak_paged_pool_usage(&self) -> usize {
63        self.as_ref().quota_peak_paged_pool_usage()
64    }
65
66    fn quota_paged_pool_usage(&self) -> usize {
67        self.as_ref().quota_paged_pool_usage()
68    }
69
70    fn quota_peak_non_paged_pool_usage(&self) -> usize {
71        self.as_ref().quota_peak_non_paged_pool_usage()
72    }
73
74    fn quota_non_paged_pool_usage(&self) -> usize {
75        self.as_ref().quota_non_paged_pool_usage()
76    }
77
78    fn pagefile_usage(&self) -> usize {
79        self.as_ref().pagefile_usage()
80    }
81
82    fn peak_pagefile_usage(&self) -> usize {
83        self.as_ref().peak_pagefile_usage()
84    }
85
86    fn private_usage(&self) -> usize {
87        self.as_ref().private_usage()
88    }
89}