Skip to content

Commit 61d40c8

Browse files
committed
runtime: extend ReadMemStatsSlow to re-compute HeapReleased
This change extends the test function ReadMemStatsSlow to re-compute the HeapReleased statistic such that it is checked in testing to be consistent with the bookkeeping done in the runtime. Change-Id: I49f5c2620f5731edea8e9f768744cf997dcd7c22 Reviewed-on: https://go-review.googlesource.com/c/142397 Run-TryBot: Michael Knyszek <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 78bb91c commit 61d40c8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/runtime/export_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ func ReadMemStatsSlow() (base, slow MemStats) {
297297
slow.TotalAlloc = 0
298298
slow.Mallocs = 0
299299
slow.Frees = 0
300+
slow.HeapReleased = 0
300301
var bySize [_NumSizeClasses]struct {
301302
Mallocs, Frees uint64
302303
}
@@ -336,6 +337,10 @@ func ReadMemStatsSlow() (base, slow MemStats) {
336337
slow.BySize[i].Frees = bySize[i].Frees
337338
}
338339

340+
mheap_.scav.treap.walkTreap(func(tn *treapNode) {
341+
slow.HeapReleased += uint64(tn.spanKey.released())
342+
})
343+
339344
getg().m.mallocing--
340345
})
341346

0 commit comments

Comments
 (0)