pub struct MemoryManager { /* private fields */ }Expand description
A memory tracker for the database instance.
In addition to a flat total_allocated counter, the manager routes every
allocation through a MemoryAccountant so the same budget can be broken
down by subsystem (buffer pool, indexes, graphs) and used to derive an
effective spill threshold for the memory governor.
Implementations§
Source§impl MemoryManager
impl MemoryManager
pub fn new(max_memory: u64) -> Self
pub fn max_memory(&self) -> u64
pub fn total_allocated(&self) -> u64
Sourcepub fn allocate(&self, amount: u64)
pub fn allocate(&self, amount: u64)
Allocate amount bytes attributed to MemoryAccountingClass::Other.
Kept for callers that do not care about attribution; prefer
MemoryManager::allocate_with.
Sourcepub fn allocate_with(&self, attr: MemoryAttribution, amount: u64)
pub fn allocate_with(&self, attr: MemoryAttribution, amount: u64)
Allocate amount bytes attributed to attr (accountable allocation).
Sourcepub fn deallocate(&self, amount: u64)
pub fn deallocate(&self, amount: u64)
Release amount bytes (unattributed). Prefer
MemoryManager::deallocate_with to keep per-class books balanced.
Sourcepub fn deallocate_with(&self, attr: MemoryAttribution, amount: u64)
pub fn deallocate_with(&self, attr: MemoryAttribution, amount: u64)
Release amount bytes previously attributed to attr.
pub fn is_under_limit(&self) -> bool
Sourcepub fn accountant(&self) -> &MemoryAccountant
pub fn accountant(&self) -> &MemoryAccountant
The accountant backing this manager (live totals break down by class).
Sourcepub fn effective_spill_threshold(&self) -> u64
pub fn effective_spill_threshold(&self) -> u64
Headroom left before the configured budget is exhausted.
Intended to be read by the spiller when deciding whether a NodeGroup / frame batch crosses the spill threshold: “how much can I still grow?”.
Sourcepub fn memory_pressure(&self) -> f64
pub fn memory_pressure(&self) -> f64
Fraction of the configured budget currently allocated, in 0.0..=1.0.
Sourcepub fn is_under_memory_pressure(&self, ratio: f64) -> bool
pub fn is_under_memory_pressure(&self, ratio: f64) -> bool
True when allocated memory consumes at least ratio of the budget.
Trait Implementations§
Source§impl Debug for MemoryManager
impl Debug for MemoryManager
Auto Trait Implementations§
impl !Freeze for MemoryManager
impl RefUnwindSafe for MemoryManager
impl Send for MemoryManager
impl Sync for MemoryManager
impl Unpin for MemoryManager
impl UnsafeUnpin for MemoryManager
impl UnwindSafe for MemoryManager
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more