memlimit

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 7 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 gives a process a soft memory limit for the Go collector, so that garbage the collector would have freed does not count against the unit's cap or the machine's memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(p Policy)

Apply sets the limit the policy gives and logs it. GOMEMLIMIT, when set, wins: the Go runtime has applied it already, and it is logged as it stands.

func CgroupMax

func CgroupMax(selfCgroup string) int64

CgroupMax is memory.max of the cgroup v2 group a /proc/<pid>/cgroup file names, 0 when there is none or it is "max".

func MachineTotal

func MachineTotal(meminfo string) int64

MachineTotal is MemTotal of a /proc/meminfo file in bytes, 0 when it cannot be read (as on a system without one).

Types

type Policy

type Policy struct {
	// CapShare is the part of the unit's memory cap the Go heap may grow to before the collector works harder; a unit
	// without a cap gives no limit of its own.
	CapShare float64
	// MachineDiv, when set, also gives a limit without a cap: the machine's memory divided by it, kept between Min
	// and Max. The smaller of the two limits wins.
	MachineDiv int64
	Min, Max   int64
}

Policy says how a process's limit follows from the memory around it.

func (Policy) Limit

func (p Policy) Limit(capBytes, machineBytes int64) (limit int64, source string)

Limit is the limit for a unit cap and a machine's memory (either 0 when unknown), and which of them gave it; 0 is no limit.

Jump to

Keyboard shortcuts

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