1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:20:22 -07:00

runtime: remove memstats.heap_alloc

memstats.heap_alloc is 100% a duplicate and unnecessary copy of
memstats.alloc which exists because MemStats used to be populated from
memstats via a memmove.

Change-Id: I995489f61be39786e573b8494a8ab6d4ea8bed9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/246975
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Michael Anthony Knyszek 2020-08-03 19:31:23 +00:00 committed by Michael Knyszek
parent c5dea8f387
commit ae585ee52c
2 changed files with 6 additions and 9 deletions

View File

@ -550,7 +550,7 @@ func dumpmemstats() {
dumpint(memstats.nlookup)
dumpint(memstats.nmalloc)
dumpint(memstats.nfree)
dumpint(memstats.heap_alloc)
dumpint(memstats.alloc)
dumpint(memstats.heap_sys.load())
dumpint(memstats.heap_sys.load() - memstats.heap_inuse)
dumpint(memstats.heap_inuse)

View File

@ -32,7 +32,6 @@ type mstats struct {
//
// Like MemStats, heap_sys and heap_inuse do not count memory
// in manually-managed spans.
heap_alloc uint64 // bytes allocated and not yet freed (same as alloc above)
heap_sys sysMemStat // virtual address space obtained from system for GC'd heap
heap_inuse uint64 // bytes in mSpanInUse spans
heap_released uint64 // bytes released to the os
@ -112,11 +111,10 @@ type mstats struct {
// heap_live is the number of bytes considered live by the GC.
// That is: retained by the most recent GC plus allocated
// since then. heap_live <= heap_alloc, since heap_alloc
// includes unmarked objects that have not yet been swept (and
// hence goes up as we allocate and down as we sweep) while
// heap_live excludes these objects (and hence only goes up
// between GCs).
// since then. heap_live <= alloc, since alloc includes unmarked
// objects that have not yet been swept (and hence goes up as we
// allocate and down as we sweep) while heap_live excludes these
// objects (and hence only goes up between GCs).
//
// This is updated atomically without locking. To reduce
// contention, this is updated only when obtaining a span from
@ -458,7 +456,7 @@ func readmemstats_m(stats *MemStats) {
stats.Sys = memstats.sys
stats.Mallocs = memstats.nmalloc
stats.Frees = memstats.nfree
stats.HeapAlloc = memstats.heap_alloc
stats.HeapAlloc = memstats.alloc
stats.HeapSys = memstats.heap_sys.load()
// By definition, HeapIdle is memory that was mapped
// for the heap but is not currently used to hold heap
@ -639,7 +637,6 @@ func updatememstats() {
// Calculate derived stats.
memstats.total_alloc = totalAlloc
memstats.alloc = totalAlloc - totalFree
memstats.heap_alloc = memstats.alloc
memstats.heap_objects = memstats.nmalloc - memstats.nfree
}