]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: reduce max arena size on windows/amd64 to 32 GiB
authorShenghou Ma <minux.ma@gmail.com>
Mon, 6 May 2013 22:53:02 +0000 (06:53 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Mon, 6 May 2013 22:53:02 +0000 (06:53 +0800)
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

index 4635e53e096a2f6bae88f176d6fc3f130c78f590..52b76d5574157309ece8f185043faa3b00b1b406 100644 (file)
@@ -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