runtime/pprof: report MaxRSS on windows

Use GetProcessMemoryInfo to report MaxRSS in memory profiles on windows.

Change-Id: I4ac5fe58961b1d5da8a5c1caa8a6e3d0a3281837
Reviewed-on: https://go-review.googlesource.com/c/go/+/424414
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Tobias Klauser 2022-08-18 19:15:20 +02:00 committed by Gopher Robot
parent dbc3b44f85
commit 2cc6983a21
2 changed files with 23 additions and 1 deletions

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows
package pprof

View File

@ -0,0 +1,22 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pprof
import (
"fmt"
"internal/syscall/windows"
"io"
"syscall"
"unsafe"
)
func addMaxRSS(w io.Writer) {
var m windows.PROCESS_MEMORY_COUNTERS
p, _ := syscall.GetCurrentProcess()
err := windows.GetProcessMemoryInfo(p, &m, uint32(unsafe.Sizeof(m)))
if err == nil {
fmt.Fprintf(w, "# MaxRSS = %d\n", m.PeakWorkingSetSize)
}
}