memsize

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepSize

func DeepSize(x interface{}) (numBytes int)

DeepSize estimates the amount of memory used by a Go value. It's intended as a memory usage debugging aid. Argument must be a pointer to a value.

Not thread safe. Behavior is undefined if any value reachable from the argument is concurrently mutated. In general, do not call this in production.

Behavior: * Recursively descends into contained values (struct fields, slice elements, etc.), tracking visitation (by memory address) to handle cycles. * Only counts slice length, not unused capacity. * Only counts map key and value size, not map overhead. * Does not count functions or channels.

The implementation relies on the Go garbage collector being non-compacting (not moving values in memory), due to thread non-safety noted above. This is true as of Go 1.13, but could change in the future.

Types

This section is empty.

Jump to

Keyboard shortcuts

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