diff options
author | Damian Gryski <[email protected]> | 2022-08-09 14:03:19 -0700 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-08-20 11:41:20 +0200 |
commit | a87e5cdbf0c823cf8fd71f8c9636b802545174d3 (patch) | |
tree | 4f2d2a6ad6a0a23e048529f6aed1a56cf2162c8d /src/runtime/gc_leaking.go | |
parent | b56baa7aad93b4ead470b4207c45169fcc4c2c40 (diff) | |
download | tinygo-a87e5cdbf0c823cf8fd71f8c9636b802545174d3.tar.gz tinygo-a87e5cdbf0c823cf8fd71f8c9636b802545174d3.zip |
runtime: add MemStats.TotalAlloc
Diffstat (limited to 'src/runtime/gc_leaking.go')
-rw-r--r-- | src/runtime/gc_leaking.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/gc_leaking.go b/src/runtime/gc_leaking.go index 536ce256b..e0a9ddc87 100644 --- a/src/runtime/gc_leaking.go +++ b/src/runtime/gc_leaking.go @@ -16,6 +16,9 @@ const gcAsserts = false // perform sanity checks // Ever-incrementing pointer: no memory is freed. var heapptr = heapStart +// Total amount allocated for runtime.MemStats +var gcTotalAlloc uint64 + // Inlining alloc() speeds things up slightly but bloats the executable by 50%, // see https://github.com/tinygo-org/tinygo/issues/2674. So don't. // @@ -26,6 +29,7 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer { // systems). size = align(size) addr := heapptr + gcTotalAlloc += uint64(size) heapptr += size for heapptr >= heapEnd { // Try to increase the heap and check again. |