pkgsitegolang.org/x/pkgsite/internal/memory Index | Files

package memory

import "golang.org/x/pkgsite/internal/memory"

Package memory provides functions to collect memory information from a variety of places.

Index

Functions

func Format

func Format(m uint64) string

Format formats a memory value for humans. It uses a B, K, M or G suffix and rounds to two decimal places.

func ReadCgroupStats

func ReadCgroupStats() (map[string]uint64, error)

ReadCgroupStats reads memory information for the current cgroup. (A cgroup is the sandbox in which a docker container runs.) All values are in bytes.

func ReadRuntimeStats

func ReadRuntimeStats() runtime.MemStats

ReadRuntimeStats is a convenience for runtime.ReadMemStats.

Types

type ProcessStats

type ProcessStats struct {
	VSize uint64 // virtual memory size
	RSS   uint64 // resident set size (physical memory in use)
}

ProcessStats holds values that describe the current process's memory. All values are in bytes.

func ReadProcessStats

func ReadProcessStats() (ProcessStats, error)

ReadProcessStats reads memory stats for the process.

type SystemStats

type SystemStats struct {
	Total     uint64
	Free      uint64
	Available uint64
	Used      uint64
	Buffers   uint64
	Cached    uint64
}

SystemStats holds values from the /proc/meminfo file, which describes the total system memory. All values are in bytes.

func ReadSystemStats

func ReadSystemStats() (SystemStats, error)

ReadSystemStats reads the /proc/meminfo file to get information about the machine.

Source Files

memory.go

Version
v0.0.0-20250218150137-224a1368cf02 (latest)
Published
Feb 18, 2025
Platform
linux/amd64
Imports
7 packages
Last checked
2 months ago

Tools for package owners.