From fac2373eba045b87019c34579770d4139e488ac7 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 13 Dec 2011 23:15:36 +0000 Subject: [PATCH] runtime: Change gc_test to test only newly allocated memory. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182315 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/go/runtime/gc_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libgo/go/runtime/gc_test.go b/libgo/go/runtime/gc_test.go index fad60a3..156d3bc 100644 --- a/libgo/go/runtime/gc_test.go +++ b/libgo/go/runtime/gc_test.go @@ -6,16 +6,24 @@ import ( ) func TestGcSys(t *testing.T) { + runtime.GC() + runtime.UpdateMemStats() + sys := runtime.MemStats.Sys + for i := 0; i < 1000000; i++ { workthegc() } // Should only be using a few MB. runtime.UpdateMemStats() - sys := runtime.MemStats.Sys - t.Logf("using %d MB", sys>>20) - if sys > 10e6 { - t.Fatalf("using too much memory: %d MB", sys>>20) + if sys > runtime.MemStats.Sys { + sys = 0 + } else { + sys = runtime.MemStats.Sys - sys + } + t.Logf("used %d extra bytes", sys) + if sys > 2<<20 { + t.Fatalf("using too much memory: %d bytes", sys) } } -- 2.7.4