Skip to content

Commit

Permalink
Merge branch 'GuillaumeGomez:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
njouanin authored Nov 3, 2023
2 parents 90bacfe + 292a568 commit 745731d
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,14 +892,14 @@ impl Process {

/// Returns the memory usage (in bytes).
///
/// This method returns the [size of the resident set](https://en.wikipedia.org/wiki/Resident_set_size),
/// that is, the amount of memory that the process allocated and that is currently mapped in physical RAM.
/// It does not include memory that is swapped out, or, in some operating systems,
/// that has been allocated but never used.
/// This method returns the [size of the resident set], that is, the amount of memory that the
/// process allocated and which is currently mapped in physical RAM. It does not include memory
/// that is swapped out, or, in some operating systems, that has been allocated but never used.
///
/// Thus, it represent exactly the amount of physical RAM that the process is using at the present time,
/// but it might not be a good indicator of the total memory that the process will be using
/// over its lifetime. For that purpose, you can try and use [`virtual_memory`](Process::virtual_memory).
/// Thus, it represents exactly the amount of physical RAM that the process is using at the
/// present time, but it might not be a good indicator of the total memory that the process will
/// be using over its lifetime. For that purpose, you can try and use
/// [`virtual_memory`](Process::virtual_memory).
///
/// ```no_run
/// use sysinfo::{Pid, System};
Expand All @@ -909,23 +909,25 @@ impl Process {
/// println!("{} bytes", process.memory());
/// }
/// ```
///
/// [size of the resident set]: https://en.wikipedia.org/wiki/Resident_set_size
pub fn memory(&self) -> u64 {
self.inner.memory()
}

/// Returns the virtual memory usage (in bytes).
///
/// This method returns the [size of virtual memory](https://en.wikipedia.org/wiki/Virtual_memory),
/// that is, the amount of memory that the process can access, whether it is currently mapped in physical RAM
/// or not. It includes physical RAM, allocated but not used regions, swapped-out regions, and even
/// memory associated with [memory-mapped files](https://en.wikipedia.org/wiki/Memory-mapped_file).
/// This method returns the [size of virtual memory], that is, the amount of memory that the
/// process can access, whether it is currently mapped in physical RAM or not. It includes
/// physical RAM, allocated but not used regions, swapped-out regions, and even memory
/// associated with [memory-mapped files](https://en.wikipedia.org/wiki/Memory-mapped_file).
///
/// Depending on the operating system and type of process, this value might be a good indicator
/// of the total memory that the process will be using over its lifetime. However, for example,
/// in the current version of MacOS this value is in the order of the hundreds of
/// gigabytes for every process, and thus not very informative. Moreover, if a process
/// maps into memory a very large file, this value will increase accordingly, even if the
/// process is not actively using the memory.
/// This value has limitations though. Depending on the operating system and type of process,
/// this value might be a good indicator of the total memory that the process will be using over
/// its lifetime. However, for example, in the version 14 of MacOS this value is in the order of
/// the hundreds of gigabytes for every process, and thus not very informative. Moreover, if a
/// process maps into memory a very large file, this value will increase accordingly, even if
/// the process is not actively using the memory.
///
/// ```no_run
/// use sysinfo::{Pid, System};
Expand All @@ -935,6 +937,8 @@ impl Process {
/// println!("{} bytes", process.virtual_memory());
/// }
/// ```
///
/// [size of virtual memory]: https://en.wikipedia.org/wiki/Virtual_memory
pub fn virtual_memory(&self) -> u64 {
self.inner.virtual_memory()
}
Expand Down

0 comments on commit 745731d

Please sign in to comment.