memlimit

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 4 Imported by: 0

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 Available added in v0.9.1

func Available() int64

Available returns the memory this process may use in bytes: the tightest of the host's physical memory and any cgroup limit applying to it. A 0 return means nothing could be detected (a non-Linux host, or an unreadable /proc), which a caller must read as "unknown", not "none".

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL