memory

package
v1.53.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package memory provides session memory measurement for the hibernation sweeper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GopsutilReader

type GopsutilReader struct{}

GopsutilReader implements Reader using gopsutil and tmux.

func NewGopsutilReader

func NewGopsutilReader() *GopsutilReader

NewGopsutilReader creates a new GopsutilReader.

func (*GopsutilReader) SessionsRSSMB added in v1.49.0

func (g *GopsutilReader) SessionsRSSMB(ctx context.Context, tmuxSessionNames []string) (map[string]int64, error)

SessionsRSSMB returns the summed RSS in MB for each of the given tmux sessions. All sessions share one processSnapshot (one system-wide process enumeration) instead of each session -- or each node in each session's process tree -- re-enumerating the system's process table on its own.

func (*GopsutilReader) SystemMemoryPct

func (g *GopsutilReader) SystemMemoryPct() (float64, error)

SystemMemoryPct returns used memory percentage via gopsutil.

type Reader

type Reader interface {
	// SystemMemoryPct returns the percentage of system RAM in use (0–100).
	// Returns 0 on platforms where measurement is unavailable.
	SystemMemoryPct() (float64, error)
	// SessionsRSSMB returns the total RSS (resident set size) in MB for each
	// of the given tmux session names, keyed by name. A session that is not
	// running or whose measurement fails maps to 0 rather than an error, so
	// one bad session doesn't fail the whole batch.
	SessionsRSSMB(ctx context.Context, tmuxSessionNames []string) (map[string]int64, error)
}

Reader reports system and per-session memory usage.

Directories

Path Synopsis
Package memorytest provides test doubles for the memory package.
Package memorytest provides test doubles for the memory package.

Jump to

Keyboard shortcuts

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