diff options
| author | Shenghou Ma <minux.ma@gmail.com> | 2014-01-14 19:23:36 -0500 |
|---|---|---|
| committer | Shenghou Ma <minux.ma@gmail.com> | 2014-01-14 19:23:36 -0500 |
| commit | 0db71338ed23324015d5d0600d2670fb3ed440b4 (patch) | |
| tree | e8ccfc9590d15a90c42db6d9586f5a5dbb995646 /src/pkg/runtime/debug/garbage.go | |
| parent | 71377d3cd3a8e9cc97258c3252717e8f0165e7fa (diff) | |
| download | go-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.go | 4 |
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 |
