MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / ApproximateMemoryUsage

Function ApproximateMemoryUsage

internal/util/memory.go:187–192  ·  view source on GitHub ↗

ApproximateMemoryUsage returns a rough estimate of the memory occupied by i. It accounts for slice capacity, string backing arrays, interface values, and deduplicates shared pointer targets. Map internal bucket overhead is not counted. Returns 0 for nil.

(i interface{})

Source from the content-addressed store, hash-verified

185// deduplicates shared pointer targets. Map internal bucket overhead is not
186// counted. Returns 0 for nil.
187func ApproximateMemoryUsage(i interface{}) uint64 {
188 if i == nil {
189 return 0
190 }
191 return uint64(sizeOf(reflect.ValueOf(i), make(map[uintptr]struct{})))
192}
193
194// MemoryUsage is an alias for ApproximateMemoryUsage retained for backwards
195// compatibility with existing callers.

Callers 1

MemoryUsageFunction · 0.85

Calls 1

sizeOfFunction · 0.85

Tested by

no test coverage detected