Allow to set a soft memory limit for the binary itself

The setting debug.memory_limit_mbytes should not be used in conjuction
with debug.force_gc because the memory limit influences the garbage
collector.
This commit is contained in:
Ingo Oppermann
2023-01-02 11:58:54 +01:00
parent 992b04d180
commit 378a3cd9cf
3 changed files with 18 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"io"
golog "log"
"math"
gonet "net"
gohttp "net/http"
"net/url"
@@ -1119,6 +1120,12 @@ func (a *api) start() error {
}(ctx)
}
if cfg.Debug.MemoryLimit > 0 {
debug.SetMemoryLimit(cfg.Debug.MemoryLimit * 1024 * 1024)
} else {
debug.SetMemoryLimit(math.MaxInt64)
}
// Start the restream processes
restream.Start()