fmt: fix usage of sync.Pool
fmt: fix usage of sync.Pool

The current usage of sync.Pool is leaky because it stores an arbitrary
sized buffer into the pool. However, sync.Pool assumes that all items in the
pool are interchangeable from a memory cost perspective. Due to the unbounded
size of a buffer that may be added, it is possible for the pool to eventually
pin arbitrarily large amounts of memory in a live-lock situation.

As a simple fix, we just set a maximum size that we permit back into the pool.

We do not need to fix the use of a sync.Pool in scan.go since the free method
has always enforced a maximum capacity since the first commit of the scan logic.

Fixes #27740
Updates #23199

Change-Id: I875278f7dba42625405df36df3e9b028252ce5e3
Reviewed-on: https://go-review.googlesource.com/136116
Reviewed-by: Bryan C. Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
Run-TryBot: Bryan C. Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>

nawawi/go,nawawi/go,josharian/go,golang/go,cloudflare/go,akutz/go,nawawi/go,CAFxX/go,nawawi/go,cloudflare/go,josharian/go,akutz/go,cloudflare/go,golang/go,CAFxX/go,cloudflare/go,akutz/go,josharian/go,golang/go,cloudflare/go,josharian/go,akutz/go,josharian/go,josharian/go,CAFxX/go,nawawi/go,CAFxX/go,nawawi/go,golang/go,golang/go,CAFxX/go,akutz/go,cloudflare/go,golang/go,nawawi/go,akutz/go,golang/go,cloudflare/go,akutz/go,akutz/go,josharian/go,CAFxX/go,cloudflare/go,nawawi/go,CAFxX/go,golang/go,CAFxX/go,josharian/go