pub struct MemoryTracker { /* private fields */ }Expand description
Memory tracker for a single Wasmtime Store.
One tracker per store. The Store::limiter closure should hand
back &mut self so Wasmtime can call memory_growing /
table_growing for resource accounting.
Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn with_byte_limit(max_memory_bytes: usize) -> Self
pub fn with_byte_limit(max_memory_bytes: usize) -> Self
Create a tracker with a byte-precision cap. Use this when the
caller already has a value in bytes (e.g. from
ExecutionLimits::max_memory_bytes) so the conversion can be
exact.
Sourcepub fn current_memory(&self) -> usize
pub fn current_memory(&self) -> usize
Current linear-memory size in bytes.
Sourcepub fn peak_memory(&self) -> usize
pub fn peak_memory(&self) -> usize
Highest linear-memory size observed in this store’s lifetime.
Sourcepub fn max_memory(&self) -> usize
pub fn max_memory(&self) -> usize
Configured upper bound in bytes.
Sourcepub fn memory_usage_percent(&self) -> f64
pub fn memory_usage_percent(&self) -> f64
Memory usage as a percentage of the configured limit.
Sourcepub fn is_memory_exceeded(&self) -> bool
pub fn is_memory_exceeded(&self) -> bool
Whether the most recent observation exceeded the cap.
Trait Implementations§
Source§impl ResourceLimiter for MemoryTracker
impl ResourceLimiter for MemoryTracker
Source§fn memory_growing(
&mut self,
current: usize,
desired: usize,
_maximum: Option<usize>,
) -> Result<bool>
fn memory_growing( &mut self, current: usize, desired: usize, _maximum: Option<usize>, ) -> Result<bool>
Notifies the resource limiter that an instance’s linear memory has been
requested to grow. Read more
Source§fn table_growing(
&mut self,
_current: usize,
_desired: usize,
_maximum: Option<usize>,
) -> Result<bool>
fn table_growing( &mut self, _current: usize, _desired: usize, _maximum: Option<usize>, ) -> Result<bool>
Notifies the resource limiter that an instance’s table has been
requested to grow. Read more
Source§fn tables(&self) -> usize
fn tables(&self) -> usize
The maximum number of tables that can be created for a
Store. Read moreSource§fn memories(&self) -> usize
fn memories(&self) -> usize
The maximum number of linear memories that can be created for a
Store Read moreSource§fn memory_grow_failed(&mut self, error: Error) -> Result<(), Error>
fn memory_grow_failed(&mut self, error: Error) -> Result<(), Error>
Notifies the resource limiter that growing a linear memory, permitted by
the
memory_growing method, has failed. Read moreAuto 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§
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§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