From 8f82bff545ed7d1f432038b7ad97e46c4bb5cf77 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Fri, 16 Nov 2012 20:06:11 +0400 Subject: [PATCH] runtime: hide mheap from race detector This significantly decreases amount of shadow memory mapped by race detector. I haven't tested on Windows, but on Linux it reduces virtual memory size from 1351m to 330m for fmt.test. Fixes #4379. R=golang-dev, alex.brainman, iant CC=golang-dev https://golang.org/cl/6849057 --- src/pkg/runtime/race.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pkg/runtime/race.c b/src/pkg/runtime/race.c index 23866f01d1..aae43852a3 100644 --- a/src/pkg/runtime/race.c +++ b/src/pkg/runtime/race.c @@ -34,9 +34,16 @@ static bool onstack(uintptr argp); void runtime·raceinit(void) { + uintptr sz; + m->racecall = true; runtime∕race·Initialize(); - runtime∕race·MapShadow(noptrdata, enoptrbss - noptrdata); + sz = (byte*)&runtime·mheap - noptrdata; + if(sz) + runtime∕race·MapShadow(noptrdata, sz); + sz = enoptrbss - (byte*)(&runtime·mheap+1); + if(sz) + runtime∕race·MapShadow(&runtime·mheap+1, sz); m->racecall = false; } -- 2.48.1