The WAMR memory model (original) (raw)

The WAMR memory categories

According to the lifecycle and associated functionalities, we put the memory used in WAMR into four categories:

Memory allocators

WAMR supports a few modes for managing the memory:

/* all the runtime memory allocations are retricted in the global_heap_buf array */  
static char global_heap_buf[512 * 1024];  
RuntimeInitArgs init_args;  
memset(&init_args, 0, sizeof(RuntimeInitArgs));  
/* configure the memory allocator for the runtime */  
init_args.mem_alloc_type = Alloc_With_Pool;  
init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;  
init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);  
wasm_runtime_full_init(&init_args);  

Runtime memory

The WAMR runtime memory:

Wasm module memory

Wasm instance

Execution environment