From 61d40c8abc82fd845b5e4340bdf0495de0de7ecd Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 15 Oct 2018 23:00:58 +0000 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Austin Clements --- src/runtime/export_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 89f887b765..56dd95e469 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -297,6 +297,7 @@ func ReadMemStatsSlow() (base, slow MemStats) { slow.TotalAlloc = 0 slow.Mallocs = 0 slow.Frees = 0 + slow.HeapReleased = 0 var bySize [_NumSizeClasses]struct { Mallocs, Frees uint64 } @@ -336,6 +337,10 @@ func ReadMemStatsSlow() (base, slow MemStats) { slow.BySize[i].Frees = bySize[i].Frees } + mheap_.scav.treap.walkTreap(func(tn *treapNode) { + slow.HeapReleased += uint64(tn.spanKey.released()) + }) + getg().m.mallocing-- })