hostmem

package
v1.0.0-rc.7 Latest Latest
Warning

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

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

Documentation

Overview

Package hostmem reads the memory of the machine this process runs on, as the kernel reports it to this process: its total and what is available. It reads /proc/meminfo only; on a system without it every read is an error, never zero.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

type Memory struct {
	TotalBytes     int64
	AvailableBytes int64
}

Memory is the machine's memory as /proc/meminfo reports it, in bytes.

func ParseMeminfo

func ParseMeminfo(b []byte) (Memory, error)

ParseMeminfo reads MemTotal and MemAvailable from a meminfo listing. Both must be present: a kernel without MemAvailable (older than 3.14) gives no honest figure for what is free.

func Read

func Read() (Memory, error)

Read reads /proc/meminfo.

func (Memory) UsedBytes

func (m Memory) UsedBytes() int64

UsedBytes is what is not available: the processes', the kernel's and the caches the kernel will not give back.

Jump to

Keyboard shortcuts

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