aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/debug
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/debug')
-rw-r--r--src/runtime/debug/garbage.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/debug/garbage.go b/src/runtime/debug/garbage.go
index c82c024235..27adc70fd3 100644
--- a/src/runtime/debug/garbage.go
+++ b/src/runtime/debug/garbage.go
@@ -90,7 +90,9 @@ func ReadGCStats(stats *GCStats) {
// A negative percentage disables garbage collection.
func SetGCPercent(percent int) int {
old := setGCPercent(int32(percent))
- runtime.GC()
+ if percent >= 0 {
+ runtime.GC()
+ }
return int(old)
}