pulumi/sdk/go/common/util
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
..
archive Prepare golangci-lint upgrade (#17065) 2024-08-28 07:57:38 +00:00
ciutil Use `SYSTEM_PULLREQUEST_SOURCECOMMITID` for AZ pipeline on GH PR (#15513) 2024-02-26 14:55:54 +00:00
cmdutil cmdutil/profile: do not defer in loop (#17581) 2024-12-10 15:10:43 +00:00
contract sdk/contract: Deprecate non-f variants 2023-03-03 14:37:59 -08:00
deepcopy disallow OutputState to be deepcopied (#16690) 2024-07-18 12:56:36 +00:00
env Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
executable Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
fsutil Install missing python versions using pyenv during installation (#16855) 2024-08-19 15:55:54 +00:00
gitutil Revert "allow URLs without template for downloading git repos (#17824)" (#17866) 2024-11-26 13:39:16 +00:00
httputil retry post requests that timeout during handshake (#16576) 2024-07-03 16:22:24 +00:00
logging Use the Depth variants in glog calls (#15307) 2024-01-29 22:51:45 +00:00
mapper turn on the golangci-lint exhaustive linter (#15028) 2024-01-17 16:50:41 +00:00
result Replace `result.Result` with native errors (#17044) 2024-08-22 14:39:59 +00:00
retry Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
rpcutil Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
yamlutil Preserve ordering when editing stack config. (#17452) 2024-10-02 13:31:10 +00:00