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>
}
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)
+ }
}