Skip to content

Commit ae585ee

Browse files
committed
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 <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Michael Knyszek <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent c5dea8f commit ae585ee

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/runtime/heapdump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ func dumpmemstats() {
550550
dumpint(memstats.nlookup)
551551
dumpint(memstats.nmalloc)
552552
dumpint(memstats.nfree)
553-
dumpint(memstats.heap_alloc)
553+
dumpint(memstats.alloc)
554554
dumpint(memstats.heap_sys.load())
555555
dumpint(memstats.heap_sys.load() - memstats.heap_inuse)
556556
dumpint(memstats.heap_inuse)

src/runtime/mstats.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ type mstats struct {
3232
//
3333
// Like MemStats, heap_sys and heap_inuse do not count memory
3434
// in manually-managed spans.
35-
heap_alloc uint64 // bytes allocated and not yet freed (same as alloc above)
3635
heap_sys sysMemStat // virtual address space obtained from system for GC'd heap
3736
heap_inuse uint64 // bytes in mSpanInUse spans
3837
heap_released uint64 // bytes released to the os
@@ -112,11 +111,10 @@ type mstats struct {
112111

113112
// heap_live is the number of bytes considered live by the GC.
114113
// That is: retained by the most recent GC plus allocated
115-
// since then. heap_live <= heap_alloc, since heap_alloc
116-
// includes unmarked objects that have not yet been swept (and
117-
// hence goes up as we allocate and down as we sweep) while
118-
// heap_live excludes these objects (and hence only goes up
119-
// between GCs).
114+
// since then. heap_live <= alloc, since alloc includes unmarked
115+
// objects that have not yet been swept (and hence goes up as we
116+
// allocate and down as we sweep) while heap_live excludes these
117+
// objects (and hence only goes up between GCs).
120118
//
121119
// This is updated atomically without locking. To reduce
122120
// contention, this is updated only when obtaining a span from
@@ -458,7 +456,7 @@ func readmemstats_m(stats *MemStats) {
458456
stats.Sys = memstats.sys
459457
stats.Mallocs = memstats.nmalloc
460458
stats.Frees = memstats.nfree
461-
stats.HeapAlloc = memstats.heap_alloc
459+
stats.HeapAlloc = memstats.alloc
462460
stats.HeapSys = memstats.heap_sys.load()
463461
// By definition, HeapIdle is memory that was mapped
464462
// for the heap but is not currently used to hold heap
@@ -639,7 +637,6 @@ func updatememstats() {
639637
// Calculate derived stats.
640638
memstats.total_alloc = totalAlloc
641639
memstats.alloc = totalAlloc - totalFree
642-
memstats.heap_alloc = memstats.alloc
643640
memstats.heap_objects = memstats.nmalloc - memstats.nfree
644641
}
645642

0 commit comments

Comments
 (0)