From: Russ Cox Date: Mon, 20 Feb 2012 03:13:04 +0000 (-0500) Subject: strconv: run garbage collection before counting allocations in test X-Git-Tag: weekly.2012-02-22~84 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a53317668a9b29cf4633e67d1d83947eee92c951;p=gostls13.git 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 --- 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