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

Commit

Permalink
Fix MemStats.Sys does not include GC heap (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored Feb 17, 2023
1 parent 66b19b3 commit 496c5c4
Showing 1 changed file with 1 addition and 4 deletions.
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

0 comments on commit 496c5c4

Please sign in to comment.