Skip to content

Commit 16c1214

Browse files
nickajacks1Nicholas Jackson
andauthored
fix: incomplete memory profile (#480)
The memory profile was being created before the main program even started, so very little relevant data was recorded. Also update the default view to total allocations since the program started rather than the current heap. Co-authored-by: Nicholas Jackson <nicholas.jackson@zii.aero>
1 parent b656d3a commit 16c1214

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,11 @@ func Main(config Config) {
307307
f, err := os.Create(pprofPath)
308308
fatalIfError(p, ctx, err)
309309
defer f.Close() // nolint: gosec
310-
runtime.GC() // get up-to-date statistics
311-
err = pprof.WriteHeapProfile(f)
312-
fatalIfError(p, ctx, err)
310+
defer func() {
311+
runtime.GC() // get up-to-date statistics
312+
err = pprof.Lookup("allocs").WriteTo(f, 0)
313+
fatalIfError(p, ctx, err)
314+
}()
313315
}
314316
err = ctx.Run(env, p, sta, config, cli.getGlobalState(), ghClient, defaultHTTPClient, cache, userConfig)
315317
fatalIfError(p, ctx, err)

0 commit comments

Comments
 (0)