Skip to main content

Advanced Wasm Memory Customization

Different Wasm workloads will be using the memory in very different ways.

Make sure you don't do changes without proper benchmarking and analysis.

It's possible to provide a custom implementation of the entire Memory used by the Wasm module:

var instance = Instance.builder(module).withMemoryFactory(limits -> {
return new ByteArrayMemory(limits);
}).build();

NOTE: Since Chicory 1.1.0, an optimized memory implementation called ByteArrayMemory is also available. We recommend plugging this implementation on all recent OpenJDK systems for enhanced performance. On different Java runtimes (in particular, on Android VMs) you should stick to ByteBufferMemory.