Documentation
¶
Overview ¶
Package memlimit reports the memory budget the process actually has, so a size derived from it (the merge cap) tracks the container it runs in rather than a constant that is right at exactly one deployment size.
It is deliberately dependency-free: the answer comes from GOMEMLIMIT, the cgroup, or the host's total memory, in that order of authority.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
func Bytes() int64
Bytes returns the memory the process may use, or 0 when nothing reports one.
GOMEMLIMIT wins when set: it is what the embedder promised the Go heap, and an embedder that applies a cgroup limit to it (automemlimit and friends) has already reserved its own headroom. Otherwise the cgroup limit is used, since a container's limit — not the host's RAM — is what the kernel kills against, and the host total is the last resort.
func MergeShare ¶
MergeShare is how many bytes one merge may hold: the total merge allowance divided across the merges that may run at once and by amplification, the peak resident per byte of the bound (a merge that holds its output twice over passes 2).
configured is the caller's total allowance: 0 takes a share of the detected process budget (Bytes), and a negative value opts out, returning math.MaxInt64 so the caller's other bounds decide alone.
func QueryShare ¶ added in v0.43.0
QueryShare is how many bytes one query may read before it is refused, derived from the process budget the same way MergeShare derives the merge allowance.
configured is the caller's cap: 0 takes a share of the detected process budget (Bytes), and a negative value opts out. Opting out returns 0 rather than math.MaxInt64, because the consumer spells "unbounded" as "install no limiter at all" — an effectively-infinite ceiling would still pay to count every byte it will never reject.
Types ¶
This section is empty.