unlimited memory on systemd engine
@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
- "math"
"strings"
"github.com/pkg/errors"
@@ -138,20 +137,19 @@ func (b *unitBuilder) buildMemoryLimit() *unitBuilder {
return b
}
- memoryLimit := int64(math.MaxInt64)
- if b.opts.Memory > 0 {
- memoryLimit = b.opts.Memory
+ if b.opts.Memory == 0 {
+ return b
}
if b.opts.SoftLimit {
b.serviceBuffer = append(b.serviceBuffer,
- fmt.Sprintf("ExecStartPre=/usr/bin/cgset -r memory.soft_limit_in_bytes=%d %s", memoryLimit, b.cgroupPath()),
+ fmt.Sprintf("ExecStartPre=/usr/bin/cgset -r memory.soft_limit_in_bytes=%d %s", b.opts.Memory, b.cgroupPath()),
)
} else {
b.serviceBuffer = append(b.serviceBuffer,
- fmt.Sprintf("ExecStartPre=/usr/bin/cgset -r memory.limit_in_bytes=%d %s", memoryLimit, b.cgroupPath()),
- fmt.Sprintf("ExecStartPre=/usr/bin/cgset -r memory.soft_limit_in_bytes=%d %s", utils.Max(int(memoryLimit/2), units.MiB*4), b.cgroupPath()),
+ fmt.Sprintf("ExecStartPre=/usr/bin/cgset -r memory.limit_in_bytes=%d %s", b.opts.Memory, b.cgroupPath()),
+ fmt.Sprintf("ExecStartPre=/usr/bin/cgset -r memory.soft_limit_in_bytes=%d %s", utils.Max(int(b.opts.Memory/2), units.MiB*4), b.cgroupPath()),
)
}
return b
