Documentation
¶
Overview ¶
Package memlimit applies the container's memory ceiling to the Go runtime.
Without it the runtime never learns the cgroup limit: GOGC defaults to 100, so the heap may grow to twice the live set before a collection is forced, regardless of how much memory the container is actually allowed to use. An executor whose live heap is ~108MiB therefore targets ~216MiB and is OOM-killed by a 256Mi limit it was never told about.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyFromCgroup ¶
func ApplyFromCgroup()
ApplyFromCgroup reads the container's memory limit and applies it to the Go runtime as a soft memory limit.
An explicit GOMEMLIMIT wins: the runtime has already applied it, and overwriting it here would silently discard an operator's setting. A missing or unlimited cgroup file leaves the runtime's own default in place, so the function never lowers a limit it could not read.
func ParseCgroupLimit ¶
ParseCgroupLimit converts a cgroup memory file's contents into a byte count.
It reports false for the three shapes that do not name a real ceiling: cgroup v2's "max", an empty file, and cgroup v1's unlimited sentinel, which the kernel publishes instead of omitting the file. A malformed or non-positive value is also rejected.
Types ¶
This section is empty.