The hidden cost of sync.Pool
In my last post, The hidden cost of mpsc channels, I discussed a common pitfall with Rust mpsc channels using more memory than intuitive (and subsequently got roasted by people pretending they read the footnotes of the documentation of every transitive dependency they use 馃檪). I recently stumbled upon a similar surprising cause of memory utilization in Go, this time in sync.Pool. sync.Pool's "purpose is to cache allocated but unused items for later reuse, relieving pressure on the garbage collector." Notice the goal is not to reduce memory usage, but to reduce allocations. However, without being familiar with the implementation details, it's easy to assume that it doesn't increase memory usage much. ...