free

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package free implements the free builtin command.

free — report host memory and swap usage

Usage: free [-h] [--help]

Display a snapshot of total, used, free, shared, buffer/cache, and available memory, plus swap usage. This is a narrow read-only investigation builtin for confirming host-level memory pressure — it is not a remediation command and does not sample repeatedly; repeated sampling and trend interpretation are out of scope (see vmstat).

Memory enumeration is delegated to the internal meminfo package, which reads /proc/meminfo on Linux. The /proc read is exempt from the AllowedPaths sandbox because the path is hardcoded and never derived from user input — the same documented exception the ss, ip route, and df builtins use. Linux only; macOS and Windows exit 1 with "not supported on this platform" (see the meminfo package doc comment for why).

Accepted flags:

-h, --human
    Print sizes in human-readable powers-of-1024 form with an IEC
    binary suffix (e.g. 1.5Gi), matching GNU free's -h.

--help
    Print usage to stdout and exit 0. No short form: -h is already
    used for human-readable output, matching GNU free.

Rejected flags (intentionally not registered, rejected as unknown by pflag with exit 1): -b/-k/-m/-g/--si/--tera/--peta unit selectors, -w/ --wide, -t/--total, -l/--lohi, and -s/--seconds + -c/--count repeated sampling. free is scoped to a single-shot snapshot; deferred to a later version if evidenced.

Exit codes:

0  Success — the memory/swap snapshot was written.
1  Error — unsupported platform, unknown flag, extra operand, or
   failure to read /proc/meminfo.

Index

Constants

This section is empty.

Variables

View Source
var Cmd = builtins.Command{
	Name:        "free",
	Description: "report host memory and swap usage",
	MakeFlags:   makeFlags,
}

Cmd is the free builtin command descriptor.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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