diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2015-10-26 12:38:47 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2015-10-26 21:14:15 +0000 |
| commit | d18167fefea5e77388dbc1e323e8527b58494185 (patch) | |
| tree | d7f7b1e5718ef3bc87d8cd02af06e90b02f1a482 /src/runtime/malloc.go | |
| parent | e6ccfc1ad14d1078428fe5f408498f925ab69670 (diff) | |
| download | go-d18167fefea5e77388dbc1e323e8527b58494185.tar.xz | |
runtime: fix tiny allocator
When a new tiny block is allocated because we're allocating an object
that won't fit into the current block, mallocgc saves the new block if
it has more space leftover than the old block. However, the logic for
this was subtly broken in golang.org/cl/2814, resulting in never
saving (or consequently reusing) a tiny block.
Change-Id: Ib5f6769451fb82877ddeefe75dfe79ed4a04fd40
Reviewed-on: https://go-review.googlesource.com/16330
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 564e2296a2..ae28a3c319 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -615,7 +615,7 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer { (*[2]uint64)(x)[1] = 0 // See if we need to replace the existing tiny block with the new one // based on amount of remaining free space. - if size < c.tinyoffset { + if size < c.tinyoffset || c.tiny == nil { c.tiny = x c.tinyoffset = size } |
