diff options
| author | Austin Clements <austin@google.com> | 2018-01-01 21:51:47 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-02-15 21:12:26 +0000 |
| commit | d7691d055a7ab39a0d437eb5e20751dc1e339c2a (patch) | |
| tree | 0ba675a54e6cd9a50345d3040604177c1f550aea /src/runtime/malloc.go | |
| parent | 90666b8a3d5545f4295d9c2517ad607ce5d45e52 (diff) | |
| download | go-d7691d055a7ab39a0d437eb5e20751dc1e339c2a.tar.xz | |
runtime: replace _MaxMem with maxAlloc
Now that we have memLimit, also having _MaxMem is a bit confusing.
Replace it with maxAlloc, which better conveys what it limits. We also
define maxAlloc slightly differently: since it's now clear that it
limits allocation size, we can account for a subtle difference between
32-bit and 64-bit.
Change-Id: Iac39048018cc0dae7f0919e25185fee4b3eed529
Reviewed-on: https://go-review.googlesource.com/85890
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index f3e738116c..299add4b35 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -196,7 +196,13 @@ const ( // // This is also the maximum heap pointer value. memLimit = 1 << memLimitBits - _MaxMem = memLimit - 1 + + // maxAlloc is the maximum size of an allocation. On 64-bit, + // it's theoretically possible to allocate memLimit bytes. On + // 32-bit, however, this is one less than memLimit because the + // number of bytes in the address space doesn't actually fit + // in a uintptr. + maxAlloc = memLimit - (1-_64bit)*1 // heapArenaBytes is the size of a heap arena. The heap // consists of mappings of size heapArenaBytes, aligned to |
