A module instance is inserted into an internal wasi-nn hashmap when wasm runtime gets wasi-nn context, but is not removed when destroying wasi-nn context, which may cause memory leak and get a stale instance or context.
I found this issue during a test where a wasi-nn enabled host application tried to load and unload a wasi-nn wasm module repeatedly. This issue looks gone after removing the instance in wasi_nn_destroy.
A module instance is inserted into an internal wasi-nn hashmap when wasm runtime gets wasi-nn context, but is not removed when destroying wasi-nn context, which may cause memory leak and get a stale instance or context.
I found this issue during a test where a wasi-nn enabled host application tried to load and unload a wasi-nn wasm module repeatedly. This issue looks gone after removing the instance in wasi_nn_destroy.