Skip to main content

nuvec_gpu/
memory.rs

1//! Allocator statistics (shared by every target).
2
3/// Memory use and limits of a device's allocator, in bytes.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub struct MemoryStats {
6    /// Bytes in live buffers (rounded allocation sizes).
7    pub active: usize,
8    /// Highest `active` since creation or the last `Device::reset_peak`.
9    pub peak: usize,
10    /// Bytes held in the cache for reuse.
11    pub cache: usize,
12    /// Allocations that would push `active` past this fail.
13    pub memory_limit: usize,
14    /// The cache is trimmed to at most this many bytes.
15    pub cache_limit: usize,
16    /// Buffers obtained from Metal (cache misses) so far.
17    pub system_allocations: u64,
18    /// Buffers are kept resident up to this many bytes (see
19    /// `Device::set_wired_limit`).
20    pub wired_limit: usize,
21    /// Bytes currently wired, including `wired_mapped`.
22    pub wired: usize,
23    /// Bytes of live memory-mapped files (checkpoints loaded without a copy). They are not
24    /// in `active` or `peak`, which count the allocator's own buffers only; MLX copies
25    /// weights into its allocator, so its `active` includes them.
26    pub mapped: usize,
27    /// The part of `wired` that belongs to memory-mapped files.
28    pub wired_mapped: usize,
29}