diff --git a/proto_package.go b/proto_package.go index a2362de..0c62bb5 100644 --- a/proto_package.go +++ b/proto_package.go @@ -220,13 +220,17 @@ func (p *ProtoPackage) build(ctx context.Context) (time.Duration, error) { log.Errorf("error getting PGID: %v", err) } - var peakMem int64 + var peakMem *int64 done := make(chan bool) - go pollMemoryUsage(pgid, 1*time.Second, done, &peakMem) + go pollMemoryUsage(pgid, 1*time.Second, done, peakMem) err = cmd.Wait() close(done) + if peakMem == nil { + log.Warningf("memory reading failed") + } + Rusage, ok := cmd.ProcessState.SysUsage().(*syscall.Rusage) if !ok { log.Panicf("rusage is not of type *syscall.Rusage, are we running on unix-like?") @@ -325,7 +329,7 @@ func (p *ProtoPackage) build(ctx context.Context) (time.Duration, error) { SetBuildTimeStart(start). SetLastVersionBuild(p.Version). SetTagRev(p.State.TagRev). - SetMaxRss(int64(peakMem)). + SetMaxRss(*peakMem). SetIoOut(Rusage.Oublock). SetIoIn(Rusage.Inblock). SetUTime(Rusage.Utime.Sec). diff --git a/utils.go b/utils.go index 62f86ac..1995971 100644 --- a/utils.go +++ b/utils.go @@ -855,8 +855,7 @@ func pollMemoryUsage(pid int, interval time.Duration, done chan bool, peakMem *i case <-done: return default: - totalRSS := int64(0) - totalSwap := int64(0) + var totalRSS, totalSwap int64 rootStats, err := getMemoryStats(pid) if err == nil {