mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-19 03:54:01 +00:00
src/runtime: add MemStats.HeapObjects
This commit is contained in:
@@ -827,6 +827,7 @@ func ReadMemStats(m *MemStats) {
|
|||||||
liveBytes := uint64(liveBlocks * bytesPerBlock)
|
liveBytes := uint64(liveBlocks * bytesPerBlock)
|
||||||
m.HeapInuse = liveBytes
|
m.HeapInuse = liveBytes
|
||||||
m.HeapAlloc = liveBytes
|
m.HeapAlloc = liveBytes
|
||||||
|
m.HeapObjects = uint64(liveHeads)
|
||||||
m.Alloc = liveBytes
|
m.Alloc = liveBytes
|
||||||
|
|
||||||
// Subtract live blocks from total blocks to count free blocks.
|
// Subtract live blocks from total blocks to count free blocks.
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ func ReadMemStats(m *MemStats) {
|
|||||||
m.Sys = uint64(heapEnd - heapStart)
|
m.Sys = uint64(heapEnd - heapStart)
|
||||||
// no free -- current in use heap is the total allocated
|
// no free -- current in use heap is the total allocated
|
||||||
m.HeapAlloc = gcTotalAlloc
|
m.HeapAlloc = gcTotalAlloc
|
||||||
|
m.HeapObjects = gcMallocs
|
||||||
m.Alloc = m.HeapAlloc
|
m.Alloc = m.HeapAlloc
|
||||||
|
|
||||||
gcLock.Unlock()
|
gcLock.Unlock()
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ type MemStats struct {
|
|||||||
// HeapReleased is bytes of physical memory returned to the OS.
|
// HeapReleased is bytes of physical memory returned to the OS.
|
||||||
HeapReleased uint64
|
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 is cumulative bytes allocated for heap objects.
|
||||||
//
|
//
|
||||||
// TotalAlloc increases as heap objects are allocated, but
|
// TotalAlloc increases as heap objects are allocated, but
|
||||||
|
|||||||
Reference in New Issue
Block a user