mirror of
https://github.com/golang/go
synced 2024-11-22 04:54:42 -07:00
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
This commit is contained in:
parent
64776da456
commit
26239417bb
@ -6,16 +6,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGcSys(t *testing.T) {
|
func TestGcSys(t *testing.T) {
|
||||||
|
runtime.GC()
|
||||||
|
runtime.UpdateMemStats()
|
||||||
|
sys := runtime.MemStats.Sys
|
||||||
|
|
||||||
for i := 0; i < 1000000; i++ {
|
for i := 0; i < 1000000; i++ {
|
||||||
workthegc()
|
workthegc()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should only be using a few MB.
|
// Should only be using a few MB.
|
||||||
runtime.UpdateMemStats()
|
runtime.UpdateMemStats()
|
||||||
sys := runtime.MemStats.Sys
|
if sys > runtime.MemStats.Sys {
|
||||||
t.Logf("using %d MB", sys>>20)
|
sys = 0
|
||||||
if sys > 10e6 {
|
} else {
|
||||||
t.Fatalf("using too much memory: %d MB", sys>>20)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user