memcheck

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(b uint64) string

FormatBytes formats a byte count as a human-readable string.

Types

type Monitor

type Monitor struct {
	LimitBytes uint64
	// contains filtered or unexported fields
}

Monitor tracks memory usage against a configured limit.

func NewMonitor

func NewMonitor(limitBytes uint64) *Monitor

NewMonitor creates a Monitor with the given memory limit in bytes.

func (*Monitor) Check

func (m *Monitor) Check() (bool, Stats)

Check reads current stats and sets the exceeded flag if Alloc >= LimitBytes. Returns whether the limit was exceeded and the current stats.

func (*Monitor) Exceeded

func (m *Monitor) Exceeded() bool

Exceeded returns whether the memory limit has been exceeded.

func (*Monitor) Reset

func (m *Monitor) Reset()

Reset clears the exceeded flag.

type Stats

type Stats struct {
	Alloc       uint64 // bytes currently allocated on heap
	TotalAlloc  uint64 // cumulative bytes allocated
	Sys         uint64 // bytes obtained from OS
	HeapObjects uint64 // number of allocated heap objects
	NumGC       uint32 // number of completed GC cycles
	Goroutines  int    // number of goroutines
}

Stats holds a snapshot of memory and runtime statistics.

func ReadStats

func ReadStats() Stats

ReadStats returns a snapshot of current memory and runtime statistics.

Jump to

Keyboard shortcuts

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