]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/debug: force GC after setting of GCPercent to make it effective.
authorShenghou Ma <minux.ma@gmail.com>
Wed, 15 Jan 2014 00:23:36 +0000 (19:23 -0500)
committerShenghou Ma <minux.ma@gmail.com>
Wed, 15 Jan 2014 00:23:36 +0000 (19:23 -0500)
See also discussion in CL 51010045.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/52230043

src/pkg/runtime/debug/garbage.go

index 8337d5d5b3477a0641db20e31b5fd93e3cbd0e3b..a724fdf8f605c0d9db6de26472aa4fc95a631cb5 100644 (file)
@@ -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