memory

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 4 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 memory reads the memory of the host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gohai added in v0.3.0

type Gohai struct {
	// Sources are what the collector reads. A zero field is the real
	// host's.
	Sources source.Sources
}

Gohai reads the host's memory with gohai's memory collector, on every Linux family and on macOS.

func New added in v0.3.0

func New() *Gohai

New returns a provider that reads the real host.

func (*Gohai) GetStats added in v0.3.0

func (g *Gohai) GetStats() (*Result, error)

GetStats is the total, available, free and cached memory, in bytes.

type Provider

type Provider interface {
	// GetStats retrieves memory statistics of the system.
	GetStats() (*Result, error)
}

Provider implements the methods to interact with various Mem components.

type Result

type Result struct {
	// Total memory in bytes
	Total uint64
	// Available memory in bytes (free + reclaimable)
	Available uint64
	// Free memory in bytes
	Free uint64
	// Cached memory in bytes
	Cached uint64
	// Changed indicates whether system state was modified.
	Changed bool `json:"changed"`
}

Result holds memory information in bytes.

func (Result) Used added in v0.3.0

func (r Result) Used() uint64

Used is the memory in use: the total less what is available, which is the free memory and what the kernel can reclaim, such as the cache. It is what free(1) calls used. It is 0 when the host reports more available than total.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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