Fix the OOMKilled error by calling debug.FreeOSMemory periodically

This commit is contained in:
M. Mert Yildiran 2021-09-14 15:22:31 +03:00
parent d5b01347df
commit fba8e5016d
No known key found for this signature in database
GPG Key ID: D42ADB236521BF7A

View File

@ -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)