Close will deallocate this engine's state explicitly. By default state is cleaned up automatically when an engine is garbage collected but the Go GC. The Go GC, however, does not provide strict guarantees about finalizers especially in terms of timing. Additionally the Go GC is not aware of the ful
()
| 55 | // Close can be called multiple times without error. Only the first time will |
| 56 | // deallocate resources. |
| 57 | func (engine *Engine) Close() { |
| 58 | if engine._ptr == nil { |
| 59 | return |
| 60 | } |
| 61 | runtime.SetFinalizer(engine, nil) |
| 62 | C.wasm_engine_delete(engine.ptr()) |
| 63 | engine._ptr = nil |
| 64 | |
| 65 | } |
| 66 | |
| 67 | func (engine *Engine) ptr() *C.wasm_engine_t { |
| 68 | ret := engine._ptr |