pub struct MemoryTracker { /* private fields */ }Expand description
Tracks memory allocations against a per-query budget.
Thread-safe via atomic operations — can be shared across parallel
query operators via Arc<MemoryTracker>.
Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn new(budget_bytes: usize) -> Self
pub fn new(budget_bytes: usize) -> Self
Create a new tracker with the given memory budget in bytes.
Sourcepub fn try_allocate(&self, bytes: usize) -> Result<()>
pub fn try_allocate(&self, bytes: usize) -> Result<()>
Try to allocate bytes from the budget.
Returns Ok(()) if the allocation succeeds, or
QueryError::QueryMemoryExceeded if the budget would be
exceeded.
§Errors
Returns an error if allocated + bytes > budget.
Sourcepub fn deallocate(&self, bytes: usize)
pub fn deallocate(&self, bytes: usize)
Release bytes back to the budget.
§Panics
Debug-asserts that bytes does not exceed the current allocation.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MemoryTracker
impl RefUnwindSafe for MemoryTracker
impl Send for MemoryTracker
impl Sync for MemoryTracker
impl Unpin for MemoryTracker
impl UnsafeUnpin for MemoryTracker
impl UnwindSafe for MemoryTracker
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
Mutably borrows from an owned value. Read more