Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Fix MemStats.Sys does not include GC heap #4

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down