Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
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 ¶
NewMonitor creates a Monitor with the given memory limit in bytes.
func (*Monitor) Check ¶
Check reads current stats and sets the exceeded flag if Alloc >= LimitBytes. Returns whether the limit was exceeded and the current stats.
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.
Click to show internal directories.
Click to hide internal directories.