Skip to content

Commit 43aac4f

Browse files
committed
runtime: raise maxmem to 512 GB
A workaround for #10460. Change-Id: I607a556561d509db6de047892f886fb565513895 Reviewed-on: https://go-review.googlesource.com/10819 Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 85b333d commit 43aac4f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/runtime/malloc.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ const (
153153
// Windows counts memory used by page table into committed memory
154154
// of the process, so we can't reserve too much memory.
155155
// See http://golang.org/issue/5402 and http://golang.org/issue/5236.
156-
// On other 64-bit platforms, we limit the arena to 128GB, or 37 bits.
156+
// On other 64-bit platforms, we limit the arena to 512GB, or 39 bits.
157157
// On 32-bit, we don't bother limiting anything, so we use the full 32-bit address.
158158
// On Darwin/arm64, we cannot reserve more than ~5GB of virtual memory,
159159
// but as most devices have less than 4GB of physical memory anyway, we
160160
// try to be conservative here, and only ask for a 2GB heap.
161-
_MHeapMap_TotalBits = (_64bit*goos_windows)*35 + (_64bit*(1-goos_windows)*(1-goos_darwin*goarch_arm64))*37 + goos_darwin*goarch_arm64*31 + (1-_64bit)*32
161+
_MHeapMap_TotalBits = (_64bit*goos_windows)*35 + (_64bit*(1-goos_windows)*(1-goos_darwin*goarch_arm64))*39 + goos_darwin*goarch_arm64*31 + (1-_64bit)*32
162162
_MHeapMap_Bits = _MHeapMap_TotalBits - _PageShift
163163

164164
_MaxMem = uintptr(1<<_MHeapMap_TotalBits - 1)
@@ -233,12 +233,12 @@ func mallocinit() {
233233
// enough to hold 4 bits per allocated word.
234234
if ptrSize == 8 && (limit == 0 || limit > 1<<30) {
235235
// On a 64-bit machine, allocate from a single contiguous reservation.
236-
// 128 GB (MaxMem) should be big enough for now.
236+
// 512 GB (MaxMem) should be big enough for now.
237237
//
238238
// The code will work with the reservation at any address, but ask
239239
// SysReserve to use 0x0000XXc000000000 if possible (XX=00...7f).
240-
// Allocating a 128 GB region takes away 37 bits, and the amd64
241-
// doesn't let us choose the top 17 bits, so that leaves the 11 bits
240+
// Allocating a 512 GB region takes away 39 bits, and the amd64
241+
// doesn't let us choose the top 17 bits, so that leaves the 9 bits
242242
// in the middle of 0x00c0 for us to choose. Choosing 0x00c0 means
243243
// that the valid memory addresses will begin 0x00c0, 0x00c1, ..., 0x00df.
244244
// In little-endian, that's c0 00, c1 00, ..., df 00. None of those are valid
@@ -248,11 +248,11 @@ func mallocinit() {
248248
// on OS X during thread allocations. 0x00c0 causes conflicts with
249249
// AddressSanitizer which reserves all memory up to 0x0100.
250250
// These choices are both for debuggability and to reduce the
251-
// odds of the conservative garbage collector not collecting memory
252-
// because some non-pointer block of memory had a bit pattern
253-
// that matched a memory address.
251+
// odds of a conservative garbage collector (as is still used in gccgo)
252+
// not collecting memory because some non-pointer block of memory
253+
// had a bit pattern that matched a memory address.
254254
//
255-
// Actually we reserve 136 GB (because the bitmap ends up being 8 GB)
255+
// Actually we reserve 544 GB (because the bitmap ends up being 32 GB)
256256
// but it hardly matters: e0 00 is not valid UTF-8 either.
257257
//
258258
// If this fails we fall back to the 32 bit memory mechanism

0 commit comments

Comments
 (0)