Skip to content

Commit

Permalink
fix: set engine to nil - sig benchmark
Browse files Browse the repository at this point in the history
In order to avoid engine leak, set engine to nil and force GC.
  • Loading branch information
rscampos committed Aug 7, 2024
1 parent 5958296 commit 5a82fd0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/signatures/benchmark/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package benchmark
import (
"context"
"fmt"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -100,6 +101,10 @@ func BenchmarkEngineWithCodeInjectionSignature(b *testing.B) {

// Start signatures engine and wait until all events are processed
e.Start(waitForEventsProcessed(inputs.Tracee))

// Set engine to nil to help with garbage collection
e = nil
runtime.GC()
}
})
}
Expand Down Expand Up @@ -149,6 +154,10 @@ func BenchmarkEngineWithMultipleSignatures(b *testing.B) {

// Start signatures engine and wait until all events are processed
e.Start(waitForEventsProcessed(inputs.Tracee))

// Set engine to nil to help with garbage collection
e = nil
runtime.GC()
}
})
}
Expand Down Expand Up @@ -211,6 +220,10 @@ func BenchmarkEngineWithNSignatures(b *testing.B) {

// Start signatures engine and wait until all events are processed
e.Start(waitForEventsProcessed(inputs.Tracee))

// Set engine to nil to help with garbage collection
e = nil
runtime.GC()
}
})
}
Expand Down

0 comments on commit 5a82fd0

Please sign in to comment.