mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-14 07:53:40 +00:00
runtime: add MemStats.TotalAlloc
This commit is contained in:
@@ -55,6 +55,7 @@ var (
|
||||
metadataStart unsafe.Pointer // pointer to the start of the heap metadata
|
||||
nextAlloc gcBlock // the next block that should be tried by the allocator
|
||||
endBlock gcBlock // the block just past the end of the available space
|
||||
gcTotalAlloc uint64 // for runtime.MemStats
|
||||
)
|
||||
|
||||
// zeroSizedAlloc is just a sentinel that gets returned when allocating 0 bytes.
|
||||
@@ -266,6 +267,8 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {
|
||||
return unsafe.Pointer(&zeroSizedAlloc)
|
||||
}
|
||||
|
||||
gcTotalAlloc += uint64(size)
|
||||
|
||||
neededBlocks := (size + (bytesPerBlock - 1)) / bytesPerBlock
|
||||
|
||||
// Continue looping until a run of free blocks has been found that fits the
|
||||
|
||||
Reference in New Issue
Block a user