aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mstats.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-12-06 17:42:42 -0500
committerAustin Clements <austin@google.com>2016-12-07 20:59:16 +0000
commit01c6a19e041f6b316c17a065f7a42b8dab57c9da (patch)
tree6a67ca68f6df3ba461a717ab3591dc2bddd8381c /src/runtime/mstats.go
parentd4177877c6d6e710d77dd8c94b91f8567f1aaa87 (diff)
downloadgo-01c6a19e041f6b316c17a065f7a42b8dab57c9da.tar.gz
go-01c6a19e041f6b316c17a065f7a42b8dab57c9da.zip
runtime: add number of forced GCs to MemStats
This adds a counter for the number of times the application forced a GC by, e.g., calling runtime.GC(). This is useful for detecting applications that are overusing/abusing runtime.GC() or debug.FreeOSMemory(). Fixes #18217. Change-Id: I990ab7a313c1b3b7a50a3d44535c460d7c54f47d Reviewed-on: https://go-review.googlesource.com/34067 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/mstats.go')
-rw-r--r--src/runtime/mstats.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index b80ab11389..4e111a14fe 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -77,6 +77,7 @@ type mstats struct {
pause_ns [256]uint64 // circular buffer of recent gc pause lengths
pause_end [256]uint64 // circular buffer of recent gc end times (nanoseconds since 1970)
numgc uint32
+ numforcedgc uint32 // number of user-forced GCs
gc_cpu_fraction float64 // fraction of CPU time used by GC
enablegc bool
debuggc bool
@@ -100,8 +101,6 @@ type mstats struct {
// must be complete.
gc_trigger uint64
- _ uint32 // force 8-byte alignment of heap_live and prevent an alignment check crash on MIPS32.
-
// heap_live is the number of bytes considered live by the GC.
// That is: retained by the most recent GC plus allocated
// since then. heap_live <= heap_alloc, since heap_alloc
@@ -365,6 +364,10 @@ type MemStats struct {
// NumGC is the number of completed GC cycles.
NumGC uint32
+ // NumForcedGC is the number of GC cycles that were forced by
+ // the application calling the GC function.
+ NumForcedGC uint32
+
// GCCPUFraction is the fraction of this program's available
// CPU time used by the GC since the program started.
//