memlimit

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

func MergeShare(configured int64, concurrency, amplification int) int64

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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