Standard library / runtime
runtime.MemProfileRecord
Sampled allocation/free counters and a stack. Use InUseBytes and InUseObjects for differences. The example uses synthetic counters. Expected stdout: '60 3\n'.
Formal Syntax & Structure
go syntaxgo
type MemProfileRecord struct { AllocBytes, FreeBytes int64 AllocObjects, FreeObjects int64 Stack0 [32]uintptr}Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { r := runtime.MemProfileRecord{AllocBytes: 100, FreeBytes: 40, AllocObjects: 5, FreeObjects: 2} fmt.Println(r.InUseBytes(), r.InUseObjects())}