meminfo

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package meminfo reads how much memory this process may still use, for code that sizes its concurrency to the machine rather than to a fixed count.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	// Total is the machine's physical memory.
	Total uint64

	// Available is the kernel's estimate of what can still be allocated
	// without pushing the system into swap. Unlike free memory it accounts for
	// reclaimable caches, and it falls as this process's heap grows — which is
	// what makes it usable as a feedback signal for admitting more workers.
	Available uint64
}

Info is a snapshot of the machine's memory, in bytes.

func Read

func Read() (Info, bool)

Read reports the memory this process may use, from /proc/meminfo narrowed by the memory limits of its cgroup and of every cgroup above it. It returns false if either figure is missing from /proc/meminfo, or if memory is under a cgroup v1 controller: its limits are not read here, and the host figures can sit far beyond them.

Jump to

Keyboard shortcuts

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