MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / resources_required

Method resources_required

crates/wasmtime/src/runtime/module.rs:965–987  ·  view source on GitHub ↗

Returns a summary of the resources required to instantiate this [`Module`]. Potential uses of the returned information: Determining whether your pooling allocator configuration supports instantiating this module. Deciding how many of which `Module` you want to instantiate within a fixed amount of resources, e.g. determining whether to create 5 instances of module X or 10 instances of module Y.

(&self)

Source from the content-addressed store, hash-verified

963 /// # Ok(()) }
964 /// ```
965 pub fn resources_required(&self) -> ResourcesRequired {
966 let em = self.env_module();
967 let num_memories = u32::try_from(em.num_defined_memories()).unwrap();
968 let max_initial_memory_size = em
969 .memories
970 .values()
971 .skip(em.num_imported_memories)
972 .map(|memory| memory.limits.min)
973 .max();
974 let num_tables = u32::try_from(em.num_defined_tables()).unwrap();
975 let max_initial_table_size = em
976 .tables
977 .values()
978 .skip(em.num_imported_tables)
979 .map(|table| table.limits.min)
980 .max();
981 ResourcesRequired {
982 num_memories,
983 max_initial_memory_size,
984 num_tables,
985 max_initial_table_size,
986 }
987 }
988
989 /// Returns the range of bytes in memory where this module's compilation
990 /// image resides.

Callers

nothing calls this directly

Calls 8

num_defined_memoriesMethod · 0.80
num_defined_tablesMethod · 0.80
env_moduleMethod · 0.45
unwrapMethod · 0.45
maxMethod · 0.45
mapMethod · 0.45
skipMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected