Browse Source

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.
Zhen Kong 2 years ago
parent
commit
1a88104160
1 changed files with 1 additions and 0 deletions
  1. 1 0
      core/iwasm/libraries/wasi-nn/src/wasi_nn.c

+ 1 - 0
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);
 }