runtime: Benchmarking reports unexpected memory allocation when using range with map structure #37757
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
In order to solve a given problem I wrote 2 variant of the same code (slightly different), one is trying to find the max value from a map structure as I'm filling it, and the second one is building the map structure first then loop over it with
range
to find the max:What did you expect to see?
As both implementations are using value semantics for the data going in and out, It was expected to see a benchmarking report of
0 allocations
for both.What did you see instead?
Solution 1
go test -bench . -gcflags -m=2 -memprofile p.out
OutputThe text was updated successfully, but these errors were encountered: