Skip to content

Commit

Permalink
fix: Aggressively GC wasm instances (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer authored May 3, 2023
1 parent 0e40fe5 commit 49c96d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2core/command/mod_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/signal"
"runtime/debug"
"syscall"
"time"

Expand Down Expand Up @@ -76,6 +77,10 @@ func ModStart() *cobra.Command {

serverErrors := make(chan error, 1)

// Wasmtime mmaps huge chunks of memory per module instantiation, so we instruct the GC to aggressively
// reclaim memory to prevent OOMs
debug.SetGCPercent(15)

go func() {
l.Info().Msg("starting server")
err := satInstance.Start()
Expand Down
1 change: 1 addition & 0 deletions sat/engine2/runtime/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (w *Instance) UseCtx(ctx *scheduler.Ctx) {
func (w *Instance) Close() {
w.inst = nil
w.ctx = nil
w.store = nil
w.resultChan = nil
w.errChan = nil
}

0 comments on commit 49c96d2

Please sign in to comment.