Documentation
¶
Overview ¶
Package sizeof provides utility functions for recursively computing the size of Go objects in memory, using the reflect package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepSize ¶
func DeepSize(v interface{}) int64
DeepSize reports the size of v in bytes, as reflect.Size, but also including all recursive substructures of v via maps, pointers, and slices. If v contains any cycles, the size of each pointer (re)introducing the cycle is included but the acyclic substructure is counted only once.
Only values whose size and structure can be obtained by the reflect package are counted. Some values have components that are not visible by reflection, and so are not counted or may be undercounted. In particular:
The space occupied by code and data, reachable through variables captured in the closure of a function pointer, are not counted. A value of function type is counted only as a pointer.
The unused buckets of a map cannot be inspected by the reflect package. Their size is estimated by assuming unfilled slots contain zeroes of their type.
The unused capacity of the array under a slice is estimated by assuming the unused slots contain zeroes of their type. It is possible they contain non zero values from sharing or reslicing, but without explicitly reslicing the reflect package cannot touch them.
Types ¶
This section is empty.