summaryrefslogtreecommitdiff
path: root/libgo/go/runtime/gc_test.go
blob: fad60a368041c7b457791f68b7345a595326e928 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package runtime_test

import (
	"runtime"
	"testing"
)

func TestGcSys(t *testing.T) {
	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)
	}
}

func workthegc() []byte {
	return make([]byte, 1029)
}