aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2011-12-13 15:12:55 -0800
committerIan Lance Taylor <iant@golang.org>2011-12-13 15:12:55 -0800
commit26239417bb0973c658a7d05e7c8b0b058562ccb8 (patch)
treee31d2741102abbc5a4621b62fa743a0c7ff01635
parent64776da456682db445462e6d095de1b2b6652a8e (diff)
downloadgo-26239417bb0973c658a7d05e7c8b0b058562ccb8.tar.gz
go-26239417bb0973c658a7d05e7c8b0b058562ccb8.zip
runtime: Make gc_test test extra allocated space, not total space.
Testing total space fails for gccgo when not using split stacks, because then each goroutine has a large stack, and so the total memory usage is large. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5487068
-rw-r--r--src/pkg/runtime/gc_test.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/pkg/runtime/gc_test.go b/src/pkg/runtime/gc_test.go
index fad60a3680..156d3bc7d3 100644
--- a/src/pkg/runtime/gc_test.go
+++ b/src/pkg/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)
}
}