runtime

package
v1.56.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableMemory added in v1.52.0

func AvailableMemory() uint64

AvailableMemory returns 75% of the memory available to this process. It reads GOMEMLIMIT (set by cobraproclimits during startup, which is cgroup-aware in Kubernetes), falling back to cgroup/system detection if GOMEMLIMIT is not set. The 75% ratio provides headroom for memory not tracked by the caller (e.g. goroutine stacks, GC metadata, fragmentation).

The detected value and its source are logged once, the first time this is called, to make percent-based-budget misconfiguration diagnosable (notably on AWS ECS, where the container memory limit may not be written to the cgroup).

func RegisterFlags

func RegisterFlags(flags *pflag.FlagSet)

RegisterFlags adds flags for configuring profiling rates.

The following flags are added: - "pprof-mutex-profile-rate" - "pprof-block-profile-rate"

func RunE

func RunE() cobrautil.CobraRunFunc

RunE returns a Cobra RunFunc that configures mutex and block profiles.

The required flags can be added to a command by using RegisterFlags().

Types

type MemorySource added in v1.55.0

type MemorySource string

MemorySource describes where the available-memory figure was derived from.

const (
	// MemorySourceGOMEMLIMIT means the figure came from GOMEMLIMIT, which is set
	// cgroup-aware at startup (and always set under Kubernetes).
	MemorySourceGOMEMLIMIT MemorySource = "GOMEMLIMIT"
	// MemorySourceDetected means GOMEMLIMIT was not usable and the figure came
	// from direct cgroup/system detection.
	MemorySourceDetected MemorySource = "cgroup/system"
	// MemorySourceUndetermined means available memory could not be determined at
	// all. Percent-based budgets (e.g. cache MaxCost) cannot be honored.
	MemorySourceUndetermined MemorySource = "undetermined"
)

Jump to

Keyboard shortcuts

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