From 1a8810416034e59657d38f8a746fd896012181ae Mon Sep 17 00:00:00 2001 From: Zhen Kong Date: Mon, 2 Oct 2023 17:33:11 -0700 Subject: [PATCH] Remove module instance from hashmap in wasi_nn_destroy (#2613) When destroying wasi-nn context, module instance should be also removed from hashmap to avoid memory leak. --- core/iwasm/libraries/wasi-nn/src/wasi_nn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c index ba27055e..c234e450 100644 --- a/core/iwasm/libraries/wasi-nn/src/wasi_nn.c +++ b/core/iwasm/libraries/wasi-nn/src/wasi_nn.c @@ -163,6 +163,7 @@ void wasi_nn_destroy(wasm_module_inst_t instance) { WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance); + bh_hash_map_remove(hashmap, (void *)instance, NULL, NULL); wasi_nn_ctx_destroy(wasi_nn_ctx); }