From 7ae3b8fa6aea5206fbc0be7fbf2fe2c7e2481d03 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Fri, 17 Feb 2023 10:39:38 +0900 Subject: [PATCH] Fix MemStats.Sys does not include GC heap --- gc.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gc.go b/gc.go index 79c5a29..566dfbe 100644 --- a/gc.go +++ b/gc.go @@ -83,10 +83,7 @@ func ReadMemStats(ms *runtime.MemStats) { gcOSBytes := C.GC_get_obtained_from_os_bytes() - // Since the GC delegates to malloc/free for underlying pages, the total memory occupied by both C malloc/free and - // the GC is malloc's peak RSS itself. Because mimalloc does not return pages when run under wasm, peak/current RSS - // and commit are all the same value and we only record one. - ms.Sys = uint64(peakRSS) + ms.Sys = uint64(peakRSS + gcOSBytes) ms.HeapSys = uint64(gcOSBytes) ms.HeapIdle = uint64(freeBytes) ms.HeapReleased = uint64(unmappedBytes)