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 ¶
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 ¶
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 {
// 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.