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.
This commit is contained in:
Zhen Kong 2023-10-02 17:33:11 -07:00 committed by GitHub
parent e1ea15d94e
commit 1a88104160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}