pulumi/sdk/go/common/util/cmdutil
Marco Molteni e82e0cbbcb
cmdutil/profile: do not defer in loop (#17581)
This fixes a defer leak that has been added during the review of #17461.

Calling defer in a loop allocates memory (stack or heap depending on the
Go version) and doesn't execute the deferred functions until the loop is
over.

In this case, since the loop runs forever, it would be even worse.

This commit proposes as fix to simply remove the defer and move the
close to its original place in the first iteration of the PR. This is
safe to do since there are no retuns in-between.

We could also refactor the loop to call instead writeMemoryProfile (as
was suggested in the PR review). In that case, if the defer is inside
writeMemoryProfile, then it can be safely called from the loop.

More info about Go defer: https://victoriametrics.com/blog/defer-in-go/
2024-12-10 15:10:43 +00:00
..
testdata Fix TestTerminate_gracefulShutdown/python flake (#16471) 2024-06-26 05:50:58 +00:00
args.go Update golangci-lint (#17972) 2024-12-10 11:50:38 +00:00
child_js.go [display] Enable WASM compilation (#16246) 2024-05-24 20:27:56 +00:00
child_unix.go [display] Enable WASM compilation (#16246) 2024-05-24 20:27:56 +00:00
child_windows.go Revert "resource/plugin: Shut down plugins gracefully (#13795)" (#13844) 2023-08-31 16:29:55 +00:00
console.go Update golangci-lint (#17972) 2024-12-10 11:50:38 +00:00
console_input.go [display] Enable WASM compilation (#16246) 2024-05-24 20:27:56 +00:00
console_input_js.go [display] Enable WASM compilation (#16246) 2024-05-24 20:27:56 +00:00
console_password.go Prepare golangci-lint upgrade (#17065) 2024-08-28 07:57:38 +00:00
console_test.go cmdutil.ReadConsole[NoEcho]: Use bubbletea (#13815) 2023-08-30 17:08:44 +00:00
diag.go Replace pkg/errors.Wrap with fmt.Errorf (#17201) 2024-09-09 11:11:46 +00:00
exit.go Prepare golangci-lint upgrade (#17065) 2024-08-28 07:57:38 +00:00
exit_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
profile.go cmdutil/profile: do not defer in loop (#17581) 2024-12-10 15:10:43 +00:00
spinner.go Add `--suppress-progresss` flag to CLI (#14690) 2024-02-05 11:48:10 +00:00
stack.go Support always qualifying stack names (#11081) (#15857) 2024-04-04 10:11:46 +00:00
term.go feat(cmdutil): TerminateProcessGroup for graceful termination (#13792) 2023-08-27 22:05:44 +00:00
term_js.go [display] Enable WASM compilation (#16246) 2024-05-24 20:27:56 +00:00
term_test.go Fix TestTerminate_gracefulShutdown/python flake (#16471) 2024-06-26 05:50:58 +00:00
term_unix.go [display] Enable WASM compilation (#16246) 2024-05-24 20:27:56 +00:00
term_windows.go feat(cmdutil): TerminateProcessGroup for graceful termination (#13792) 2023-08-27 22:05:44 +00:00
trace.go Reimport appdash from our mirror (#14701) 2023-11-30 14:21:35 +00:00