mirror of
https://github.com/golang/go
synced 2024-11-22 18:54:44 -07:00
runtime/pprof: check Getrusage return value in addMaxRSS
Depending on the implementation of the getrusage syscall/function, the value of rusage.Maxrss may be undefined in case of an error. Thus, only report MaxRSS in case of no error. Change-Id: I7572ccc53c49eb460e53bded3eb41736eed8d2ed Reviewed-on: https://go-review.googlesource.com/c/go/+/424815 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Joedian Reid <joedian@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
2cc6983a21
commit
2e06019dcd
@ -28,6 +28,8 @@ func addMaxRSS(w io.Writer) {
|
||||
}
|
||||
|
||||
var rusage syscall.Rusage
|
||||
syscall.Getrusage(syscall.RUSAGE_SELF, &rusage)
|
||||
fmt.Fprintf(w, "# MaxRSS = %d\n", uintptr(rusage.Maxrss)*rssToBytes)
|
||||
err := syscall.Getrusage(syscall.RUSAGE_SELF, &rusage)
|
||||
if err == nil {
|
||||
fmt.Fprintf(w, "# MaxRSS = %d\n", uintptr(rusage.Maxrss)*rssToBytes)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user