aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-11-26 21:16:43 +0000
committerMichael Knyszek <mknyszek@google.com>2019-11-27 15:06:55 +0000
commit4e3d58009a1ba08e41dd1ec33691120a76a06af9 (patch)
tree3188239b979b27355a27324c87bef947d4dae82d /src
parent22688f740dbbae281c1de09c2b4fe6520337a124 (diff)
downloadgo-4e3d58009a1ba08e41dd1ec33691120a76a06af9.tar.xz
runtime: reset scavenge address in scavengeAll
Currently scavengeAll (which is called by debug.FreeOSMemory) doesn't reset the scavenge address before scavenging, meaning it could miss large portions of the heap. Fix this by reseting the address before scavenging, which will ensure it is able to walk over the entire heap. Fixes #35858. Change-Id: I4a7408050b8e134318ff94428f98cb96a1795aa9 Reviewed-on: https://go-review.googlesource.com/c/go/+/208960 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mheap.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go
index 3f3e36728b..114c97b874 100644
--- a/src/runtime/mheap.go
+++ b/src/runtime/mheap.go
@@ -1424,6 +1424,8 @@ func (h *mheap) scavengeAll() {
gp := getg()
gp.m.mallocing++
lock(&h.lock)
+ // Reset the scavenger address so we have access to the whole heap.
+ h.pages.resetScavengeAddr()
released := h.pages.scavenge(^uintptr(0), true)
unlock(&h.lock)
gp.m.mallocing--