Trait forest_filecoin::shim::fvm_latest::machine::limiter::MemoryLimiter
source · pub trait MemoryLimiter: Sized {
// Required methods
fn memory_used(&self) -> usize;
fn grow_memory(&mut self, delta: usize) -> bool;
fn with_stack_frame<T, G, F, R>(t: &mut T, g: G, f: F) -> R
where G: Fn(&mut T) -> &mut Self,
F: FnOnce(&mut T) -> R;
// Provided methods
fn grow_instance_memory(&mut self, from: usize, to: usize) -> bool { ... }
fn grow_instance_table(&mut self, from: u32, to: u32) -> bool { ... }
}
Expand description
Execution level memory tracking and adjustment.
Required Methods§
sourcefn memory_used(&self) -> usize
fn memory_used(&self) -> usize
Get a snapshot of the total memory required by the callstack (in bytes). This currently includes:
- Memory used by tables (8 bytes per element).
- Memory used by wasmtime instances.
In the future, this will likely be extended to include IPLD blocks, actor code, etc.
sourcefn grow_memory(&mut self, delta: usize) -> bool
fn grow_memory(&mut self, delta: usize) -> bool
Returns true
if growing by delta
bytes is allowed. Implement this memory to track and
limit memory usage.
Provided Methods§
sourcefn grow_instance_memory(&mut self, from: usize, to: usize) -> bool
fn grow_instance_memory(&mut self, from: usize, to: usize) -> bool
Grows an instance’s memory from from
to to
. There’s no need to manually implement this
unless you need to track instance metrics.
sourcefn grow_instance_table(&mut self, from: u32, to: u32) -> bool
fn grow_instance_table(&mut self, from: u32, to: u32) -> bool
Grows an instance’s table from from
to to
elements. There’s no need to manually
implement this unless you need to track table metrics.
Object Safety§
This trait is not object safe.