fix memory val not geeting updated

This commit is contained in:
2025-03-22 21:46:51 +01:00
parent daf6f13542
commit 48c66d429a
2 changed files with 8 additions and 5 deletions

View File

@@ -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).

View File

@@ -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 {