The work buffer management used by the garbage
collector during parallel collections leaks buffers.
This CL tests for and fixes the leak.
R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/
5254059
--- /dev/null
+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)
+}
runtimeĀ·lock(&work.emu);
b->next = work.empty;
- work.empty = b->next;
+ work.empty = b;
runtimeĀ·unlock(&work.emu);
}
gomake testshort
) || exit $?
+(xcd pkg/runtime;
+gotest -short -cpu=1,2,4
+) || exit $?
+
(xcd pkg/sync;
GOMAXPROCS=10 gomake testshort
) || exit $?