memprof

package
v0.29.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reporter

type Reporter interface {
	Run(ctx context.Context) error
}

Reporter periodically inspects the process's memory and, once it crosses a threshold, logs where that memory is going.

It exists because a container that is OOMKilled at its cgroup limit is otherwise opaque: the process dies without saying what grew, and the runtime metrics on /metrics say only *how much*, never *which code*. A heap profile would answer that, but only if something can reach the debug endpoint — which is exactly what is unavailable when the pod is crash-looping behind a cluster-internal Service. This reporter writes the same information to the service log, which is readable with nothing but `kubectl logs`.

func New

func New(interval time.Duration, thresholdBytes uint64, topN int) Reporter

New returns a Reporter that ticks every interval and, when the Go heap in use or the container's cgroup usage reaches thresholdBytes, logs a breakdown.

Both signals are checked because they fail independently: the cgroup figure includes page cache, so a container can sit at its limit with a tiny heap, while a runaway allocation can exceed the threshold long before the cgroup notices. Reporting only one would miss the other's failure mode.

topN bounds how many allocation sites are logged per report, largest first.

Jump to

Keyboard shortcuts

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