Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/runtime/gc_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ func ReadMemStats(m *MemStats) {
liveBytes := uint64(liveBlocks * bytesPerBlock)
m.HeapInuse = liveBytes
m.HeapAlloc = liveBytes
m.HeapObjects = uint64(liveHeads)
m.Alloc = liveBytes

// Subtract live blocks from total blocks to count free blocks.
Expand Down
1 change: 1 addition & 0 deletions src/runtime/gc_leaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func ReadMemStats(m *MemStats) {
m.Sys = uint64(heapEnd - heapStart)
// no free -- current in use heap is the total allocated
m.HeapAlloc = gcTotalAlloc
m.HeapObjects = gcMallocs
m.Alloc = m.HeapAlloc

gcLock.Unlock()
Expand Down
7 changes: 7 additions & 0 deletions src/runtime/mstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ type MemStats struct {
// HeapReleased is bytes of physical memory returned to the OS.
HeapReleased uint64

// HeapObjects is the number of allocated heap objects.
//
// Like HeapAlloc, this increases as objects are allocated and
// decreases as the heap is swept and unreachable objects are
// freed.
HeapObjects uint64

// TotalAlloc is cumulative bytes allocated for heap objects.
//
// TotalAlloc increases as heap objects are allocated, but
Expand Down
Loading