procfs_core

Struct Meminfo

source
#[non_exhaustive]
pub struct Meminfo {
Show 63 fields pub mem_total: u64, pub mem_free: u64, pub mem_available: Option<u64>, pub buffers: u64, pub cached: u64, pub swap_cached: u64, pub active: u64, pub inactive: u64, pub active_anon: Option<u64>, pub inactive_anon: Option<u64>, pub active_file: Option<u64>, pub inactive_file: Option<u64>, pub unevictable: Option<u64>, pub mlocked: Option<u64>, pub high_total: Option<u64>, pub high_free: Option<u64>, pub low_total: Option<u64>, pub low_free: Option<u64>, pub mmap_copy: Option<u64>, pub swap_total: u64, pub swap_free: u64, pub dirty: u64, pub writeback: u64, pub anon_pages: Option<u64>, pub mapped: u64, pub shmem: Option<u64>, pub slab: u64, pub s_reclaimable: Option<u64>, pub s_unreclaim: Option<u64>, pub kernel_stack: Option<u64>, pub page_tables: Option<u64>, pub secondary_page_tables: Option<u64>, pub quicklists: Option<u64>, pub nfs_unstable: Option<u64>, pub bounce: Option<u64>, pub writeback_tmp: Option<u64>, pub commit_limit: Option<u64>, pub committed_as: u64, pub vmalloc_total: u64, pub vmalloc_used: u64, pub vmalloc_chunk: u64, pub hardware_corrupted: Option<u64>, pub anon_hugepages: Option<u64>, pub shmem_hugepages: Option<u64>, pub shmem_pmd_mapped: Option<u64>, pub cma_total: Option<u64>, pub cma_free: Option<u64>, pub hugepages_total: Option<u64>, pub hugepages_free: Option<u64>, pub hugepages_rsvd: Option<u64>, pub hugepages_surp: Option<u64>, pub hugepagesize: Option<u64>, pub direct_map_4k: Option<u64>, pub direct_map_4M: Option<u64>, pub direct_map_2M: Option<u64>, pub direct_map_1G: Option<u64>, pub hugetlb: Option<u64>, pub per_cpu: Option<u64>, pub k_reclaimable: Option<u64>, pub file_pmd_mapped: Option<u64>, pub file_huge_pages: Option<u64>, pub z_swap: Option<u64>, pub z_swapped: Option<u64>,
}
Expand description

This struct reports statistics about memory usage on the system, based on the /proc/meminfo file.

It is used by free(1) to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel. Each struct member is generally reported in bytes, but a few are unitless values.

Except as noted below, all of the fields have been present since at least Linux 2.6.0. Some fields are optional and are present only if the kernel was configured with various options; those dependencies are noted in the list.

Notes

While the file shows kilobytes (kB; 1 kB equals 1000 B), it is actually kibibytes (KiB; 1 KiB equals 1024 B).

All sizes are converted to bytes. Unitless values, like hugepages_total are not affected.

This imprecision in /proc/meminfo is known, but is not corrected due to legacy concerns - programs rely on /proc/meminfo to specify size with the “kB” string.

New fields to this struct may be added at any time (even without a major or minor semver bump).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§mem_total: u64

Total usable RAM (i.e., physical RAM minus a few reserved bits and the kernel binary code).

§mem_free: u64

The sum of LowFree + HighFree.

§mem_available: Option<u64>

An estimate of how much memory is available for starting new applications, without swapping.

(since Linux 3.14)

§buffers: u64

Relatively temporary storage for raw disk blocks that shouldn’t get tremendously large (20MB or so).

§cached: u64

In-memory cache for files read from the disk (the page cache). Doesn’t include SwapCached.

§swap_cached: u64

Memory that once was swapped out, is swapped back in but still also is in the swap file.

(If memory pressure is high, these pages don’t need to be swapped out again because they are already in the swap file. This saves I/O.)

§active: u64

Memory that has been used more recently and usually not reclaimed unless absolutely necessary.

§inactive: u64

Memory which has been less recently used. It is more eligible to be reclaimed for other purposes.

§active_anon: Option<u64>

[To be documented.]

(since Linux 2.6.28)

§inactive_anon: Option<u64>

[To be documented.]

(since Linux 2.6.28)

§active_file: Option<u64>

[To be documented.]

(since Linux 2.6.28)

§inactive_file: Option<u64>

[To be documented.]

(since Linux 2.6.28)

§unevictable: Option<u64>

[To be documented.]

(From Linux 2.6.28 to 2.6.30, CONFIG_UNEVICTABLE_LRU was required.)

§mlocked: Option<u64>

[To be documented.]

(From Linux 2.6.28 to 2.6.30, CONFIG_UNEVICTABLE_LRU was required.)

§high_total: Option<u64>

Total amount of highmem.

Highmem is all memory above ~860MB of physical memory. Highmem areas are for use by user-space programs, or for the page cache. The kernel must use tricks to access this memory, making it slower to access than lowmem.

(Starting with Linux 2.6.19, CONFIG_HIGHMEM is required.)

§high_free: Option<u64>

Amount of free highmem.

(Starting with Linux 2.6.19, CONFIG_HIGHMEM is required.)

§low_total: Option<u64>

Total amount of lowmem.

Lowmem is memory which can be used for every thing that highmem can be used for, but it is also available for the kernel’s use for its own data structures. Among many other things, it is where everything from Slab is allocated. Bad things happen when you’re out of lowmem.

(Starting with Linux 2.6.19, CONFIG_HIGHMEM is required.)

§low_free: Option<u64>

Amount of free lowmem.

(Starting with Linux 2.6.19, CONFIG_HIGHMEM is required.)

§mmap_copy: Option<u64>

[To be documented.]

(since Linux 2.6.29. CONFIG_MMU is required.)

§swap_total: u64

Total amount of swap space available.

§swap_free: u64

Amount of swap space that is currently unused.

§dirty: u64

Memory which is waiting to get written back to the disk.

§writeback: u64

Memory which is actively being written back to the disk.

§anon_pages: Option<u64>

Non-file backed pages mapped into user-space page tables.

(since Linux 2.6.18)

§mapped: u64

Files which have been mapped into memory (with mmap(2)), such as libraries.

§shmem: Option<u64>

Amount of memory consumed in tmpfs(5) filesystems.

(since Linux 2.6.32)

§slab: u64

In-kernel data structures cache.

§s_reclaimable: Option<u64>

Part of Slab, that can be reclaimed on memory pressure.

(since Linux 2.6.19)

§s_unreclaim: Option<u64>

Part of Slab, that cannot be reclaimed on memory pressure.

(since Linux 2.6.19)

§kernel_stack: Option<u64>

Amount of memory allocated to kernel stacks.

(since Linux 2.6.32)

§page_tables: Option<u64>

Amount of memory dedicated to the lowest level of page tables.

(since Linux 2.6.18)

§secondary_page_tables: Option<u64>

Amount of memory allocated for seconary page tables. This currently includes KVM mmu allocations on x86 and arm64.

(since Linux 6.1)

§quicklists: Option<u64>

[To be documented.]

(CONFIG_QUICKLIST is required. Since Linux 2.6.27)

§nfs_unstable: Option<u64>

NFS pages sent to the server, but not yet committed to stable storage.

(since Linux 2.6.18)

§bounce: Option<u64>

Memory used for block device “bounce buffers”.

(since Linux 2.6.18)

§writeback_tmp: Option<u64>

Memory used by FUSE for temporary writeback buffers.

(since Linux 2.6.26)

§commit_limit: Option<u64>

This is the total amount of memory currently available to be allocated on the system, expressed in bytes.

This limit is adhered to only if strict overcommit accounting is enabled (mode 2 in /proc/sys/vm/overcommit_memory). The limit is calculated according to the formula described under /proc/sys/vm/overcommit_memory. For further details, see the kernel source file Documentation/vm/overcommit-accounting.

(since Linux 2.6.10)

§committed_as: u64

The amount of memory presently allocated on the system.

The committed memory is a sum of all of the memory which has been allocated by processes, even if it has not been “used” by them as of yet. A process which allocates 1GB of memory (using malloc(3) or similar), but touches only 300MB of that memory will show up as using only 300MB of memory even if it has the address space allocated for the entire 1GB.

This 1GB is memory which has been “committed” to by the VM and can be used at any time by the allocating application. With strict overcommit enabled on the system (mode 2 in /proc/sys/vm/overcommit_memory), allocations which would exceed the Committed_AS mitLimit will not be permitted. This is useful if one needs to guarantee that processes will not fail due to lack of memory once that memory has been successfully allocated.

§vmalloc_total: u64

Total size of vmalloc memory area.

§vmalloc_used: u64

Amount of vmalloc area which is used.

§vmalloc_chunk: u64

Largest contiguous block of vmalloc area which is free.

§hardware_corrupted: Option<u64>

[To be documented.]

(CONFIG_MEMORY_FAILURE is required. Since Linux 2.6.32)

§anon_hugepages: Option<u64>

Non-file backed huge pages mapped into user-space page tables.

(CONFIG_TRANSPARENT_HUGEPAGE is required. Since Linux 2.6.38)

§shmem_hugepages: Option<u64>

Memory used by shared memory (shmem) and tmpfs(5) allocated with huge pages

(CONFIG_TRANSPARENT_HUGEPAGE is required. Since Linux 4.8)

§shmem_pmd_mapped: Option<u64>

Shared memory mapped into user space with huge pages.

(CONFIG_TRANSPARENT_HUGEPAGE is required. Since Linux 4.8)

§cma_total: Option<u64>

Total CMA (Contiguous Memory Allocator) pages.

(CONFIG_CMA is required. Since Linux 3.1)

§cma_free: Option<u64>

Free CMA (Contiguous Memory Allocator) pages.

(CONFIG_CMA is required. Since Linux 3.1)

§hugepages_total: Option<u64>

The size of the pool of huge pages.

CONFIG_HUGETLB_PAGE is required.)

§hugepages_free: Option<u64>

The number of huge pages in the pool that are not yet allocated.

(CONFIG_HUGETLB_PAGE is required.)

§hugepages_rsvd: Option<u64>

This is the number of huge pages for which a commitment to allocate from the pool has been made, but no allocation has yet been made.

These reserved huge pages guarantee that an application will be able to allocate a huge page from the pool of huge pages at fault time.

(CONFIG_HUGETLB_PAGE is required. Since Linux 2.6.17)

§hugepages_surp: Option<u64>

This is the number of huge pages in the pool above the value in /proc/sys/vm/nr_hugepages.

The maximum number of surplus huge pages is controlled by /proc/sys/vm/nr_overcommit_hugepages.

(CONFIG_HUGETLB_PAGE is required. Since Linux 2.6.24)

§hugepagesize: Option<u64>

The size of huge pages.

(CONFIG_HUGETLB_PAGE is required.)

§direct_map_4k: Option<u64>

Number of bytes of RAM linearly mapped by kernel in 4kB pages. (x86.)

(since Linux 2.6.27)

§direct_map_4M: Option<u64>

Number of bytes of RAM linearly mapped by kernel in 4MB pages.

(x86 with CONFIG_X86_64 or CONFIG_X86_PAE enabled. Since Linux 2.6.27)

§direct_map_2M: Option<u64>

Number of bytes of RAM linearly mapped by kernel in 2MB pages.

(x86 with neither CONFIG_X86_64 nor CONFIG_X86_PAE enabled. Since Linux 2.6.27)

§direct_map_1G: Option<u64>

(x86 with CONFIG_X86_64 and CONFIG_X86_DIRECT_GBPAGES enabled. Since Linux 2.6.27)

§hugetlb: Option<u64>

needs documentation

§per_cpu: Option<u64>

Memory allocated to the per-cpu alloctor used to back per-cpu allocations.

This stat excludes the cost of metadata.

§k_reclaimable: Option<u64>

Kernel allocations that the kernel will attempt to reclaim under memory pressure.

Includes s_reclaimable, and other direct allocations with a shrinker.

§file_pmd_mapped: Option<u64>

Undocumented field

(CONFIG_TRANSPARENT_HUGEPAGE is requried. Since Linux 5.4)

§file_huge_pages: Option<u64>

Undocumented field

(CONFIG_TRANSPARENT_HUGEPAGE is required. Since Linux 5.4)

§z_swap: Option<u64>

Memory consumed by the zswap backend (compressed size).

(CONFIG_ZSWAP is required. Since Linux 5.19)

§z_swapped: Option<u64>

Amount of anonymous memory stored in zswap (original size).

(CONFIG_ZSWAP is required. Since Linux 5.19)

Trait Implementations§

source§

impl Clone for Meminfo

source§

fn clone(&self) -> Meminfo

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Meminfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Meminfo

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FromBufRead for Meminfo

source§

impl Serialize for Meminfo

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRead for T
where T: FromBufRead,

source§

fn from_read<R>(r: R) -> Result<T, ProcError>
where R: Read,

Read the type from a Read.
source§

fn from_file<P: AsRef<Path>>(path: P) -> ProcResult<Self>

Read the type from a file.
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,