diff options
Diffstat (limited to 'src/pkg/runtime/debug.go')
-rw-r--r-- | src/pkg/runtime/debug.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/pkg/runtime/debug.go b/src/pkg/runtime/debug.go index b65cc6693..3ce35cc5b 100644 --- a/src/pkg/runtime/debug.go +++ b/src/pkg/runtime/debug.go @@ -4,6 +4,8 @@ package runtime +import "unsafe" + // Breakpoint() executes a breakpoint trap. func Breakpoint() @@ -26,6 +28,9 @@ func GOMAXPROCS(n int) int // Cgocalls returns the number of cgo calls made by the current process. func Cgocalls() int64 +// Goroutines returns the number of goroutines that currently exist. +func Goroutines() int32 + type MemStatsType struct { // General statistics. // Not locked during update; approximate. @@ -36,10 +41,11 @@ type MemStatsType struct { Mallocs uint64 // number of mallocs // Main allocation heap statistics. - HeapAlloc uint64 // bytes allocated and still in use - HeapSys uint64 // bytes obtained from system - HeapIdle uint64 // bytes in idle spans - HeapInuse uint64 // bytes in non-idle span + HeapAlloc uint64 // bytes allocated and still in use + HeapSys uint64 // bytes obtained from system + HeapIdle uint64 // bytes in idle spans + HeapInuse uint64 // bytes in non-idle span + HeapObjects uint64 // total number of allocated objects // Low-level fixed-size structure allocator statistics. // Inuse is bytes used now. @@ -69,6 +75,15 @@ type MemStatsType struct { } } +var sizeof_C_MStats int // filled in by malloc.goc + +func init() { + if sizeof_C_MStats != unsafe.Sizeof(MemStats) { + println(sizeof_C_MStats, unsafe.Sizeof(MemStats)) + panic("MStats vs MemStatsType size mismatch") + } +} + // MemStats holds statistics about the memory system. // The statistics are only approximate, as they are not interlocked on update. var MemStats MemStatsType |