aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/debug/garbage.go
diff options
context:
space:
mode:
authorShenghou Ma <minux.ma@gmail.com>2014-01-14 19:23:36 -0500
committerShenghou Ma <minux.ma@gmail.com>2014-01-14 19:23:36 -0500
commit0db71338ed23324015d5d0600d2670fb3ed440b4 (patch)
treee8ccfc9590d15a90c42db6d9586f5a5dbb995646 /src/pkg/runtime/debug/garbage.go
parent71377d3cd3a8e9cc97258c3252717e8f0165e7fa (diff)
downloadgo-0db71338ed23324015d5d0600d2670fb3ed440b4.tar.xz
runtime/debug: force GC after setting of GCPercent to make it effective.
See also discussion in CL 51010045. R=golang-codereviews, r CC=golang-codereviews https://golang.org/cl/52230043
Diffstat (limited to 'src/pkg/runtime/debug/garbage.go')
-rw-r--r--src/pkg/runtime/debug/garbage.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pkg/runtime/debug/garbage.go b/src/pkg/runtime/debug/garbage.go
index 8337d5d5b3..a724fdf8f6 100644
--- a/src/pkg/runtime/debug/garbage.go
+++ b/src/pkg/runtime/debug/garbage.go
@@ -91,7 +91,9 @@ func (x byDuration) Less(i, j int) bool { return x[i] < x[j] }
// at startup, or 100 if the variable is not set.
// A negative percentage disables garbage collection.
func SetGCPercent(percent int) int {
- return setGCPercent(percent)
+ old := setGCPercent(percent)
+ runtime.GC()
+ return old
}
// FreeOSMemory forces a garbage collection followed by an