From a53317668a9b29cf4633e67d1d83947eee92c951 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Feb 2012 22:13:04 -0500 Subject: [PATCH] strconv: run garbage collection before counting allocations in test My theory is that the call to f() allocates, which triggers a garbage collection, which itself may do some allocation, which is being counted. Running a garbage collection before starting the test should avoid this problem. Fixes #2894 (I hope). R=golang-dev, bradfitz, nigeltao CC=golang-dev https://golang.org/cl/5685046 --- src/pkg/strconv/itoa_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pkg/strconv/itoa_test.go b/src/pkg/strconv/itoa_test.go index 6687314d2f..1486ee214d 100644 --- a/src/pkg/strconv/itoa_test.go +++ b/src/pkg/strconv/itoa_test.go @@ -127,6 +127,7 @@ func TestUitoa(t *testing.T) { } func numAllocations(f func()) int { + runtime.GC() memstats := new(runtime.MemStats) runtime.ReadMemStats(memstats) n0 := memstats.Mallocs -- 2.50.0