OSDN Git Service

Update to current version of Go library.
[pf3gnuchains/gcc-fork.git] / libgo / go / runtime / mem.go
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 type MemStatsType struct {
10         // General statistics.
11         // Not locked during update; approximate.
12         Alloc      uint64 // bytes allocated and still in use
13         TotalAlloc uint64 // bytes allocated (even if freed)
14         Sys        uint64 // bytes obtained from system (should be sum of XxxSys below)
15         Lookups    uint64 // number of pointer lookups
16         Mallocs    uint64 // number of mallocs
17         Frees      uint64 // number of frees
18
19         // Main allocation heap statistics.
20         HeapAlloc   uint64 // bytes allocated and still in use
21         HeapSys     uint64 // bytes obtained from system
22         HeapIdle    uint64 // bytes in idle spans
23         HeapInuse   uint64 // bytes in non-idle span
24         HeapObjects uint64 // total number of allocated objects
25
26         // Low-level fixed-size structure allocator statistics.
27         //      Inuse is bytes used now.
28         //      Sys is bytes obtained from system.
29         StackInuse  uint64 // bootstrap stacks
30         StackSys    uint64
31         MSpanInuse  uint64 // mspan structures
32         MSpanSys    uint64
33         MCacheInuse uint64 // mcache structures
34         MCacheSys   uint64
35         BuckHashSys uint64 // profiling bucket hash table
36
37         // Garbage collector statistics.
38         NextGC       uint64
39         PauseTotalNs uint64
40         PauseNs      [256]uint64 // most recent GC pause times
41         NumGC        uint32
42         EnableGC     bool
43         DebugGC      bool
44
45         // Per-size allocation statistics.
46         // Not locked during update; approximate.
47         // 61 is NumSizeClasses in the C code.
48         BySize [61]struct {
49                 Size    uint32
50                 Mallocs uint64
51                 Frees   uint64
52         }
53 }
54
55 var Sizeof_C_MStats int // filled in by malloc.goc
56
57 func init() {
58         if Sizeof_C_MStats != unsafe.Sizeof(MemStats) {
59                 println(Sizeof_C_MStats, unsafe.Sizeof(MemStats))
60                 panic("MStats vs MemStatsType size mismatch")
61         }
62 }
63
64 // MemStats holds statistics about the memory system.
65 // The statistics are only approximate, as they are not interlocked on update.
66 var MemStats MemStatsType
67
68 // GC runs a garbage collection.
69 func GC()