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
This commit is contained in:
Shenghou Ma 2014-01-14 19:23:36 -05:00
parent 71377d3cd3
commit 0db71338ed

View 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