memwatch

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	B   = 1
	KiB = 1 << (10 * iota) // 2^10
	MiB = 1 << (10 * iota) // 2^20
	GiB = 1 << (10 * iota) // 2^30
	TiB = 1 << (10 * iota) // 2^40
)

Variables

View Source
var ErrNotEnoughMemory = fmt.Errorf("not enough memory")

Functions

This section is empty.

Types

type Monitor

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

Monitor allows making statements about the memory ratio used by the application

func NewMonitor

func NewMonitor(profiler memProfiler, limitSetter limitSetter,
	rate int, maxRatio float64,
) *Monitor

NewMonitor creates a Monitor with the given profiler, limitsetter and rate.

Typically this would be called with runtime.MemProfile, debug.SetMemoryLimit, and runtime.MemProfileRate

func (*Monitor) CheckAlloc added in v1.22.0

func (m *Monitor) CheckAlloc(sizeInBytes int64) error

func (*Monitor) Ratio

func (m *Monitor) Ratio() float64

func (*Monitor) Refresh added in v1.22.0

func (m *Monitor) Refresh()

Refresh retrieves the current memory stats from the runtime and stores them in the local cache

Jump to

Keyboard shortcuts

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