Documentation
¶
Overview ¶
Package memlimit sets a soft heap ceiling (GOMEMLIMIT) so a large scan makes the garbage collector work harder instead of OOM-killing the process.
The Go GC's default target heap is ~2x the live set (GOGC=100). A whole-repo scan with dependency lowering can hold several GiB live during the SSA build+lower phase; doubling that reaches the host's RAM and the kernel SIGKILLs the process even though the working set itself fits. Pinning GOMEMLIMIT to a fraction of available memory keeps the heap under the ceiling: slower under pressure, but the scan finishes instead of dying.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
func Configure() int64
Configure sets GOMEMLIMIT to softFraction of the memory available to the process, and returns the limit in bytes (0 if it left the runtime default in place). It is a no-op when GOMEMLIMIT is already set in the environment (Go reads that automatically, so an operator's deliberate choice is respected) or when available memory cannot be detected (e.g. a non-Linux host).
Types ¶
This section is empty.