]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: extend ReadMemStatsSlow to re-compute HeapReleased
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 15 Oct 2018 23:00:58 +0000 (23:00 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 30 Oct 2018 15:28:07 +0000 (15:28 +0000)
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 <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/export_test.go

index 89f887b765db6aa83db2d2fd35d9e180453e7dd5..56dd95e4697d745defb52946e4b9c62a4532750c 100644 (file)
@@ -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--
        })