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{})
| 185 | // deduplicates shared pointer targets. Map internal bucket overhead is not |
| 186 | // counted. Returns 0 for nil. |
| 187 | func 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. |