github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/runtime/mem.go (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package runtime 6 7 import "unsafe" 8 9 // Note: the MemStats struct should be kept in sync with 10 // struct MStats in malloc.h 11 12 // A MemStats records statistics about the memory allocator. 13 type MemStats struct { 14 // General statistics. 15 Alloc uint64 // bytes allocated and still in use 16 TotalAlloc uint64 // bytes allocated (even if freed) 17 Sys uint64 // bytes obtained from system (sum of XxxSys below) 18 Lookups uint64 // number of pointer lookups 19 Mallocs uint64 // number of mallocs 20 Frees uint64 // number of frees 21 22 // Main allocation heap statistics. 23 HeapAlloc uint64 // bytes allocated and still in use 24 HeapSys uint64 // bytes obtained from system 25 HeapIdle uint64 // bytes in idle spans 26 HeapInuse uint64 // bytes in non-idle span 27 HeapReleased uint64 // bytes released to the OS 28 HeapObjects uint64 // total number of allocated objects 29 30 // Low-level fixed-size structure allocator statistics. 31 // Inuse is bytes used now. 32 // Sys is bytes obtained from system. 33 StackInuse uint64 // bootstrap stacks 34 StackSys uint64 35 MSpanInuse uint64 // mspan structures 36 MSpanSys uint64 37 MCacheInuse uint64 // mcache structures 38 MCacheSys uint64 39 BuckHashSys uint64 // profiling bucket hash table 40 GCSys uint64 // GC metadata 41 OtherSys uint64 // other system allocations 42 43 // Garbage collector statistics. 44 NextGC uint64 // next run in HeapAlloc time (bytes) 45 LastGC uint64 // last run in absolute time (ns) 46 PauseTotalNs uint64 47 PauseNs [256]uint64 // circular buffer of recent GC pause times, most recent at [(NumGC+255)%256] 48 NumGC uint32 49 EnableGC bool 50 DebugGC bool 51 52 // Per-size allocation statistics. 53 // 61 is NumSizeClasses in the C code. 54 BySize [61]struct { 55 Size uint32 56 Mallocs uint64 57 Frees uint64 58 } 59 } 60 61 var sizeof_C_MStats uintptr // filled in by malloc.goc 62 63 var memStats MemStats 64 65 func init() { 66 if sizeof_C_MStats != unsafe.Sizeof(memStats) { 67 println(sizeof_C_MStats, unsafe.Sizeof(memStats)) 68 panic("MStats vs MemStatsType size mismatch") 69 } 70 } 71 72 // ReadMemStats populates m with memory allocator statistics. 73 func ReadMemStats(m *MemStats) 74 75 // GC runs a garbage collection. 76 func GC()