Skip to content

Commit

Permalink
compiler: add munmap finalizer on cache hits to avoid memory leak
Browse files Browse the repository at this point in the history
Signed-off-by: Val Packett <[email protected]>
  • Loading branch information
valpackett committed Oct 24, 2023
1 parent 610fdbd commit 52dcc4a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/engine/compiler/engine_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func (e *engine) getCompiledModule(module *wasm.Module, listeners []experimental
cm.functions[i].listener = listeners[i]
}
}

// As this uses mmap, we need to munmap on the compiled machine code when it's GCed.
e.setFinalizer(cm, releaseCompiledModule)
}
return
}
Expand Down

0 comments on commit 52dcc4a

Please sign in to comment.