memlimit

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memlimit sets the Go runtime's soft memory limit from the container's memory limit, for the operator and the engine.

Index

Constants

View Source
const Env = "MEMORY_LIMIT"

Env has the container's memory limit in bytes: the chart (operator) and the injected engine set it from the downward API (resourceFieldRef limits.memory). Without a limit, Kubernetes gives the node's allocatable memory.

Variables

This section is empty.

Functions

func Detect added in v0.6.0

func Detect(getenv func(string) string, root fs.FS) (int64, string)

Detect returns Limit and where the container's limit came from: Env, or without it (a plain container: docker run --memory), the file of the process's cgroup that has it, cgroup v2's memory.max or v1's memory.limit_in_bytes, read from root (nil: no cgroup is read). "" when there is no limit.

func Limit

func Limit(getenv func(string) string) int64

Limit returns the Go runtime's soft memory limit: 90% of the container's memory limit, the rest left for what the runtime doesn't manage. 0 when GOMEMLIMIT is set (the runtime applied it) or no limit is known.

The heap goal is otherwise twice the live heap at the last GC, so the RSS of a busy process reaches the container limit long before its live heap does (0004 §8). With a limit, the GC runs more often near it.

func Set

func Set(getenv func(string) string) (int64, string)

Set applies Detect, with the root filesystem's cgroup, if there is a limit, and returns it and where it came from.

Types

This section is empty.

Jump to

Keyboard shortcuts

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