memory

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferPool

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

type Config

type Config struct {
	SmallBufferSize  int
	MediumBufferSize int
	LargeBufferSize  int

	MaxSmallBuffers  int
	MaxMediumBuffers int
	MaxLargeBuffers  int

	CleanupInterval time.Duration

	MemoryPressureThreshold float64
	GCTriggerThreshold      float64
}

func DefaultConfig

func DefaultConfig() *Config

type HeaderPool

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

type Manager

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

func NewManager

func NewManager(config *Config) *Manager

func (*Manager) Close

func (m *Manager) Close() error

Close shuts down the memory manager

func (*Manager) GetBuffer

func (m *Manager) GetBuffer(size int) []byte

GetBuffer returns a buffer of appropriate size

func (*Manager) GetHeaders

func (m *Manager) GetHeaders() map[string]string

GetHeaders returns a header map from the pool

func (*Manager) GetStats

func (m *Manager) GetStats() Stats

GetStats returns current memory statistics

func (*Manager) PutBuffer

func (m *Manager) PutBuffer(buf []byte)

func (*Manager) PutHeaders

func (m *Manager) PutHeaders(headers map[string]string)

PutHeaders returns a header map to the pool

type Stats

type Stats struct {
	SmallBuffersInUse  int64
	MediumBuffersInUse int64
	LargeBuffersInUse  int64
	SmallBuffersTotal  int64
	MediumBuffersTotal int64
	LargeBuffersTotal  int64

	HeadersInUse int64
	HeadersTotal int64

	AllocatedBytes int64
	SystemBytes    int64
	GCCycles       int64
	LastGCTime     int64

	BufferHitRate  float64
	ObjectHitRate  float64
	MemoryPressure float64

	LastUpdate int64
}

Jump to

Keyboard shortcuts

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