From fba8e5016d17d40d57b1e65578d28d5b621ca051 Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Tue, 14 Sep 2021 15:22:31 +0300 Subject: [PATCH] Fix the OOMKilled error by calling `debug.FreeOSMemory` periodically --- tap/passive_tapper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tap/passive_tapper.go b/tap/passive_tapper.go index d4aec99f3..2930cf284 100644 --- a/tap/passive_tapper.go +++ b/tap/passive_tapper.go @@ -18,6 +18,7 @@ import ( "os" "os/signal" "runtime" + _debug "runtime/debug" "runtime/pprof" "strconv" "strings" @@ -218,6 +219,7 @@ func closeTimedoutTcpStreamChannels() { maxNumberOfGoroutines = GetMaxNumberOfGoroutines() TcpStreamChannelTimeoutMs := GetTcpChannelTimeoutMs() for { + _debug.FreeOSMemory() time.Sleep(10 * time.Millisecond) streams.Range(func(key interface{}, value interface{}) bool { streamWrapper := value.(*tcpStreamWrapper)