From b3b1efd88291c63b9717db190ded45df2ef8c243 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Tue, 7 May 2013 06:53:02 +0800 Subject: runtime: reduce max arena size on windows/amd64 to 32 GiB Update #5236 Update #5402 This CL reduces gofmt's committed memory from 545864 KiB to 139568 KiB. Note: Go 1.0.3 uses about 70MiB. R=golang-dev, r, iant, nightlyone CC=golang-dev https://golang.org/cl/9245043 --- src/pkg/runtime/malloc.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index 4635e53e09..52b76d5574 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -115,10 +115,18 @@ enum HeapAllocChunk = 1<<20, // Chunk size for heap growth // Number of bits in page to span calculations (4k pages). - // On 64-bit, we limit the arena to 128GB, or 37 bits. + // On Windows 64-bit we limit the arena to 32GB or 35 bits (see below for reason). + // On other 64-bit platforms, we limit the arena to 128GB, or 37 bits. // On 32-bit, we don't bother limiting anything, so we use the full 32-bit address. #ifdef _64BIT +#ifdef GOOS_windows + // Windows counts memory used by page table into committed memory + // of the process, so we can't reserve too much memory. + // See http://golang.org/issue/5402 and http://golang.org/issue/5236. + MHeapMap_Bits = 35 - PageShift, +#else MHeapMap_Bits = 37 - PageShift, +#endif #else MHeapMap_Bits = 32 - PageShift, #endif @@ -134,7 +142,7 @@ enum // This must be a #define instead of an enum because it // is so large. #ifdef _64BIT -#define MaxMem (1ULL<<(MHeapMap_Bits+PageShift)) /* 128 GB */ +#define MaxMem (1ULL<<(MHeapMap_Bits+PageShift)) /* 128 GB or 32 GB */ #else #define MaxMem ((uintptr)-1) #endif -- cgit v1.2.3-54-g00ecf