Commit 26239417 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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
parent 64776da4
......@@ -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)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment