manual

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Free

func Free(purpose Purpose, b Buf)

Free frees the specified slice. It has to be exactly the slice that was returned by New.

Types

type Buf added in v2.1.0

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

Buf is a buffer allocated using this package.

func MakeBufUnsafe added in v2.1.0

func MakeBufUnsafe(data unsafe.Pointer, n uintptr) Buf

MakeBufUnsafe should be used with caution: the given data and n must match exactly the data and length of a Buf obtained from New. It is useful when these are stored implicitly in another type (like a []byte) and we want to reconstruct the Buf.

func New

func New(purpose Purpose, n uintptr) Buf

New allocates a slice of size n. The returned slice is from manually managed memory and MUST be released by calling Free. Failure to do so will result in a memory leak.

func (Buf) Data added in v2.1.0

func (b Buf) Data() unsafe.Pointer

Data returns a pointer to the buffer data. If the buffer is not initialized (or is the result of calling New with a zero length), returns nil.

func (Buf) Len added in v2.1.0

func (b Buf) Len() uintptr

func (Buf) Slice added in v2.1.0

func (b Buf) Slice() []byte

Slice converts the buffer to a byte slice.

type Metrics

type Metrics [NumPurposes]struct {
	// InUseBytes is the total number of bytes currently allocated. This is just
	// the sum of the lengths of the allocations and does not include any overhead
	// or fragmentation.
	InUseBytes uint64
}

Metrics contains memory statistics by purpose.

func GetMetrics

func GetMetrics() Metrics

GetMetrics returns manual memory usage statistics.

type Purpose

type Purpose uint8

Purpose identifies the use-case for an allocation.

const (
	BlockCacheMap Purpose
	BlockCacheEntry
	BlockCacheData
	MemTable

	NumPurposes
)

Jump to

Keyboard shortcuts

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