aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-04-29 09:44:53 -0400
committerAustin Clements <austin@google.com>2016-04-29 15:25:26 +0000
commitd97625ae9e7195a68d1c9f2b2ff54eb85545982e (patch)
tree04ec959353f9eed3aee1329ff94542993175b5a5 /src/runtime/malloc.go
parent6d11490539e3aa459066b94c6587f5429dfe7a31 (diff)
downloadgo-d97625ae9e7195a68d1c9f2b2ff54eb85545982e.tar.xz
[dev.garbage] runtime: fix nfree accounting
Commit 8dda1c4 changed the meaning of "nfree" in sweep from the number of newly freed objects to the total number of free objects in the span, but didn't update where sweep added nfree to c.local_nsmallfree. Hence, we're over-accounting the number of frees. This is causing TestArrayHash to fail with "too many allocs NNN - hash not balanced". Fix this by computing the number of newly freed objects and adding that to c.local_nsmallfree, so it behaves like it used to. Computing this requires a small tweak to mallocgc: apparently we've never set s.allocCount when allocating a large object; fix this by setting it to 1 so sweep doesn't get confused. Change-Id: I31902ffd310110da4ffd807c5c06f1117b872dc8 Reviewed-on: https://go-review.googlesource.com/22595 Reviewed-by: Rick Hudson <rlh@golang.org> Run-TryBot: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/malloc.go')
-rw-r--r--src/runtime/malloc.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 2ac504f9dc..438cd06161 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -696,6 +696,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
s = largeAlloc(size, needzero)
})
s.freeindex = 1
+ s.allocCount = 1
x = unsafe.Pointer(s.base())
size = s.elemsize
}