aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime/gc_leaking.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-12-15 17:36:02 +0100
committerAyke <[email protected]>2023-01-17 19:32:18 +0100
commitfb730743256db73cb922f00dac92ba5b312da530 (patch)
tree035f07ec38053e0924d53a306edbe1752189d7cb /src/runtime/gc_leaking.go
parent187d9c6aca05f129cd71801488bb54a7aa4c3508 (diff)
downloadtinygo-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.go17
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.
}