Commit 9f75ecd5 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

runtime/debug: don't run a GC when setting SetGCPercent negative

If the user is calling SetGCPercent(-1), they intend to disable GC.
They probably don't intend to run one. If they do, they can call
runtime.GC themselves.

Change-Id: I40ef40dfc7e15193df9ff26159cd30e56b666f73
Reviewed-on: https://go-review.googlesource.com/34013
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 2a74b9e8
......@@ -90,7 +90,9 @@ func ReadGCStats(stats *GCStats) {
// A negative percentage disables garbage collection.
func SetGCPercent(percent int) int {
old := setGCPercent(int32(percent))
if percent >= 0 {
runtime.GC()
}
return int(old)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment