Skip to content

Commit 8375fdf

Browse files
committed
Clear allocator when closing instance
1 parent a8f2533 commit 8375fdf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/runtime/wasmer/instance.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,23 +237,25 @@ func (in *Instance) SetContextStorage(s runtime.Storage) {
237237
in.ctx.Storage = s
238238
}
239239

240-
// Stop closes the instance (wasm instance and its imports)
241-
// in a thread-safe way.
240+
// Stop closes the WASM instance, its imports and clears
241+
// the context allocator in a thread-safe way.
242242
func (in *Instance) Stop() {
243243
in.mutex.Lock()
244244
defer in.mutex.Unlock()
245245
in.close()
246246
}
247247

248248
// close closes the wasm instance (and its imports)
249-
// if the instance has not been previously closed.
249+
// and clears the context allocator. If the instance
250+
// has previously been closed, it simply returns.
250251
// It is NOT THREAD SAFE to use.
251252
func (in *Instance) close() {
252253
if in.isClosed {
253254
return
254255
}
255256

256257
in.vm.Close()
258+
in.ctx.Allocator.Clear()
257259
in.isClosed = true
258260
}
259261

0 commit comments

Comments
 (0)