diff options
author | Ayke van Laethem <[email protected]> | 2022-12-15 17:36:02 +0100 |
---|---|---|
committer | Ayke <[email protected]> | 2023-01-17 19:32:18 +0100 |
commit | fb730743256db73cb922f00dac92ba5b312da530 (patch) | |
tree | 035f07ec38053e0924d53a306edbe1752189d7cb /src/runtime/gc_leaking.go | |
parent | 187d9c6aca05f129cd71801488bb54a7aa4c3508 (diff) | |
download | tinygo-fb730743256db73cb922f00dac92ba5b312da530.tar.gz tinygo-fb730743256db73cb922f00dac92ba5b312da530.zip |
runtime: move GC code around to prepare for precise GC
Most of the code of the conservative GC can be reused for the precise
GC. So before adding precise GC support, this commit just moves code
around to make the next commit cleaner. It is a non-functional change.
Diffstat (limited to 'src/runtime/gc_leaking.go')
-rw-r--r-- | src/runtime/gc_leaking.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/runtime/gc_leaking.go b/src/runtime/gc_leaking.go index a01642507..2f2bdff17 100644 --- a/src/runtime/gc_leaking.go +++ b/src/runtime/gc_leaking.go @@ -64,6 +64,23 @@ func free(ptr unsafe.Pointer) { // Memory is never freed. } +// ReadMemStats populates m with memory statistics. +// +// The returned memory statistics are up to date as of the +// call to ReadMemStats. This would not do GC implicitly for you. +func ReadMemStats(m *MemStats) { + m.HeapIdle = 0 + m.HeapInuse = gcTotalAlloc + m.HeapReleased = 0 // always 0, we don't currently release memory back to the OS. + + m.HeapSys = m.HeapInuse + m.HeapIdle + m.GCSys = 0 + m.TotalAlloc = gcTotalAlloc + m.Mallocs = gcMallocs + m.Frees = gcFrees + m.Sys = uint64(heapEnd - heapStart) +} + func GC() { // No-op. } |