onsi / gomega

Ginkgo's Preferred Matcher Library
http://onsi.github.io/gomega/
MIT License
2.19k stars 284 forks source link

`work` channel in `gmeasure.Experiment.Sample` is not closed upon return #579

Open davidhsingyuchen opened 2 years ago

davidhsingyuchen commented 2 years ago

My understanding is that the goruotines will still be waiting on range work even after Example.Sample returns, and the fact that those goroutines are still referencing the work channel may further prevent the channel itself from being garbage collected. Please let me know if I'm missing anything, thanks!

onsi commented 2 years ago

oh hey - sorry for the delay. that's a good catch. we need to close the work channel.

thediveo commented 2 years ago

cough gleak 😁

onsi commented 2 years ago

In fact! https://github.com/onsi/gomega/commit/119d4cea3d32068752e4285e256e231d9748757a and https://github.com/onsi/gomega/commit/8c54344b7bc6a1091fe7f1b674ae1cb9cccc850a

Super satisfying :)

thediveo commented 2 years ago

...it just caught me these days leaking worker pools. Not that I'm not full of good intentions to not leak, yet ... well, you know...