pub struct Limits {
pub memory_bytes: usize,
pub stack_bytes: usize,
pub load_budget: Duration,
pub call_budget: Duration,
pub max_op_values: usize,
pub max_canvas_ops: usize,
pub max_nodes: usize,
}Expand description
Resource limits of one VM.
Fields§
§memory_bytes: usizeQuickJS heap, in bytes (0: no limit). Running out stops the VM.
stack_bytes: usizeInterpreter stack, in bytes: deep recursion becomes a RangeError
rather than a native stack overflow. Must stay below the engine
thread’s stack.
load_budget: DurationEvaluating the bundle (Duration::MAX: no limit).
call_budget: DurationAny other call into JS: one event (with the rendering it causes), one
list bind, one timer, one frame’s callbacks, the microtask drain
(Duration::MAX: no limit).
max_op_values: usizeChanges JS may make at once (the op queue’s length): they are held in
Rust memory, which the heap limit does not cover (usize::MAX: no
limit).
max_canvas_ops: usizeOperations one canvas drawing may record (usize::MAX: no limit).
max_nodes: usizeNodes the core keeps (each may have a native view, whose memory the
heap limit does not cover either; usize::MAX: no limit).
Implementations§
Source§impl Limits
impl Limits
Sourcepub fn standalone() -> Limits
pub fn standalone() -> Limits
The limits of an app nsh runs on its own (the hosts and runners of
every platform, a web package, nsh run without --limits): none
but the interpreter stack’s, which turns deep recursion into a
RangeError instead of a crash of the process.
Sourcepub fn development(spec: Option<&str>) -> Result<Limits, String>
pub fn development(spec: Option<&str>) -> Result<Limits, String>
The limits of a development host’s app: those an embedding app
would set (spec, as HostLimits::parse reads it: nsh run --limits, which the dev server passes on), or none
(Limits::standalone) without a spec.
Trait Implementations§
impl Copy for Limits
Source§impl Default for Limits
The limits of an app embedded in a host app (NshAppView, NshView,
AppView) that sets none: a 256 MB heap, 10 s to load, 2 s per call.
impl Default for Limits
The limits of an app embedded in a host app (NshAppView, NshView,
AppView) that sets none: a 256 MB heap, 10 s to load, 2 s per call.