pub struct MemoryMonitor { /* private fields */ }Expand description
Memory monitor for tracking process memory usage
This is a lightweight implementation that tracks an estimated memory budget
without requiring the sysinfo crate. In production, you may want to
integrate with platform-specific memory APIs.
Implementations§
Source§impl MemoryMonitor
impl MemoryMonitor
pub fn new(max_memory_mb: usize, enabled: bool) -> Self
Sourcepub fn check_memory_limit(&self) -> Result<()>
pub fn check_memory_limit(&self) -> Result<()>
Check if current memory usage exceeds the limit
This is a lightweight check. For precise memory monitoring, consider enabling platform-specific memory tracking.
Sourcepub fn get_current_memory_mb(&self) -> u64
pub fn get_current_memory_mb(&self) -> u64
Get current memory usage in MB (returns 0 in lightweight mode)
Sourcepub fn get_memory_percentage(&self) -> f64
pub fn get_memory_percentage(&self) -> f64
Get memory usage percentage (returns 0.0 in lightweight mode)
Auto Trait Implementations§
impl Freeze for MemoryMonitor
impl RefUnwindSafe for MemoryMonitor
impl Send for MemoryMonitor
impl Sync for MemoryMonitor
impl Unpin for MemoryMonitor
impl UnsafeUnpin for MemoryMonitor
impl UnwindSafe for MemoryMonitor
Blanket Implementations§
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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