LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package runtime | 5 package runtime |
6 | 6 |
7 import "unsafe" | 7 import "unsafe" |
8 | 8 |
9 // A MemStats records statistics about the memory allocator. | 9 // A MemStats records statistics about the memory allocator. |
10 type MemStats struct { | 10 type MemStats struct { |
11 // General statistics. | 11 // General statistics. |
12 Alloc uint64 // bytes allocated and still in use | 12 Alloc uint64 // bytes allocated and still in use |
13 TotalAlloc uint64 // bytes allocated (even if freed) | 13 TotalAlloc uint64 // bytes allocated (even if freed) |
14 Sys uint64 // bytes obtained from system (should be sum of XxxSys
below) | 14 Sys uint64 // bytes obtained from system (should be sum of XxxSys
below) |
15 Lookups uint64 // number of pointer lookups | 15 Lookups uint64 // number of pointer lookups |
16 Mallocs uint64 // number of mallocs | 16 Mallocs uint64 // number of mallocs |
17 Frees uint64 // number of frees | 17 Frees uint64 // number of frees |
18 | 18 |
19 // Main allocation heap statistics. | 19 // Main allocation heap statistics. |
20 » HeapAlloc uint64 // bytes allocated and still in use | 20 » HeapAlloc uint64 // bytes allocated and still in use |
21 » HeapSys uint64 // bytes obtained from system | 21 » HeapSys uint64 // bytes obtained from system |
22 » HeapIdle uint64 // bytes in idle spans | 22 » HeapIdle uint64 // bytes in idle spans |
23 » HeapInuse uint64 // bytes in non-idle span | 23 » HeapInuse uint64 // bytes in non-idle span |
24 » HeapObjects uint64 // total number of allocated objects | 24 » HeapReleased uint64 // bytes released to the OS |
| 25 » HeapObjects uint64 // total number of allocated objects |
25 | 26 |
26 // Low-level fixed-size structure allocator statistics. | 27 // Low-level fixed-size structure allocator statistics. |
27 // Inuse is bytes used now. | 28 // Inuse is bytes used now. |
28 // Sys is bytes obtained from system. | 29 // Sys is bytes obtained from system. |
29 StackInuse uint64 // bootstrap stacks | 30 StackInuse uint64 // bootstrap stacks |
30 StackSys uint64 | 31 StackSys uint64 |
31 MSpanInuse uint64 // mspan structures | 32 MSpanInuse uint64 // mspan structures |
32 MSpanSys uint64 | 33 MSpanSys uint64 |
33 MCacheInuse uint64 // mcache structures | 34 MCacheInuse uint64 // mcache structures |
34 MCacheSys uint64 | 35 MCacheSys uint64 |
35 BuckHashSys uint64 // profiling bucket hash table | 36 BuckHashSys uint64 // profiling bucket hash table |
36 | 37 |
37 // Garbage collector statistics. | 38 // Garbage collector statistics. |
38 » NextGC uint64 | 39 » NextGC uint64 // next run in HeapAlloc time (bytes) |
| 40 » LastGC uint64 // last run in absolute time (ns) |
39 PauseTotalNs uint64 | 41 PauseTotalNs uint64 |
40 PauseNs [256]uint64 // most recent GC pause times | 42 PauseNs [256]uint64 // most recent GC pause times |
41 NumGC uint32 | 43 NumGC uint32 |
42 EnableGC bool | 44 EnableGC bool |
43 DebugGC bool | 45 DebugGC bool |
44 | 46 |
45 // Per-size allocation statistics. | 47 // Per-size allocation statistics. |
46 // 61 is NumSizeClasses in the C code. | 48 // 61 is NumSizeClasses in the C code. |
47 BySize [61]struct { | 49 BySize [61]struct { |
48 Size uint32 | 50 Size uint32 |
(...skipping 11 matching lines...) Expand all Loading... |
60 println(sizeof_C_MStats, unsafe.Sizeof(memStats)) | 62 println(sizeof_C_MStats, unsafe.Sizeof(memStats)) |
61 panic("MStats vs MemStatsType size mismatch") | 63 panic("MStats vs MemStatsType size mismatch") |
62 } | 64 } |
63 } | 65 } |
64 | 66 |
65 // ReadMemStats populates m with memory allocator statistics. | 67 // ReadMemStats populates m with memory allocator statistics. |
66 func ReadMemStats(m *MemStats) | 68 func ReadMemStats(m *MemStats) |
67 | 69 |
68 // GC runs a garbage collection. | 70 // GC runs a garbage collection. |
69 func GC() | 71 func GC() |
LEFT | RIGHT |