memoryutils

package
v5.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableMemoryLogs

func EnableMemoryLogs(enabled bool)

EnableMemoryLogs enables memory tracking logs

func IsMemoryLogsEnabled

func IsMemoryLogsEnabled() bool

IsMemoryLogsEnabled returns whether memory logs are enabled

func LogMemoryAndMessageSize

func LogMemoryAndMessageSize(ctx context.Context, stage string, messageSize int, additionalAttrs ...utils.Attribute)

LogMemoryAndMessageSize logs memory stats and message size with context

func StartMemoryGC

func StartMemoryGC(ctx context.Context, thresholdGB float64)

StartMemoryGC starts a goroutine that monitors heap memory usage and calls GC when heap in use exceeds the threshold. If thresholdGB is 0, the routine is disabled. The goroutine runs until ctx is cancelled.

Types

type MemoryProfiler

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

MemoryProfiler helps track memory changes over time

func NewMemoryProfiler

func NewMemoryProfiler() *MemoryProfiler

NewMemoryProfiler creates a new memory profiler

func (*MemoryProfiler) GetDelta

func (mp *MemoryProfiler) GetDelta() map[string]interface{}

GetDelta returns the change in memory since profiler creation

func (*MemoryProfiler) LogDelta

func (mp *MemoryProfiler) LogDelta(ctx context.Context, stage string, additionalAttrs ...utils.Attribute)

LogDelta logs the memory delta

type MemoryStats

type MemoryStats struct {
	AllocMB        float64
	TotalAllocMB   float64
	SysMB          float64
	NumGC          uint32
	HeapAllocMB    float64
	HeapSysMB      float64
	HeapIdleMB     float64
	HeapInUseMB    float64
	StackInUseMB   float64
	GoroutineCount int
}

MemoryStats holds current memory statistics

func GetMemoryStats

func GetMemoryStats() *MemoryStats

GetMemoryStats returns current memory statistics

Jump to

Keyboard shortcuts

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