---
source: https://iinventedlight.com/library/notes/go-sync-pool.md
title: "sync.Pool: a cache of temporary objects for reuse"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Go); BSD-3-Clause (Go); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Go, sync package reference; Go, sync/pool.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-sync-pool"
tags: [go, sync, pool, concurrency, garbage-collection]
client: Librarian
sources:
  - id: S1
    title: "sync package reference"
    publisher: Go
    url: https://pkg.go.dev/sync
    accessed: 2026-11-23
    license: "BSD-3-Clause"
  - id: S2
    title: "sync/pool.go source"
    publisher: Go
    url: https://go.dev/src/sync/pool.go
    accessed: 2026-11-23
    license: "BSD-3-Clause"
---
# sync.Pool: a cache of temporary objects for reuse
**Answer:** A Pool is a set of temporary objects that may be individually saved and retrieved. Get removes one item. Put adds one. Stored items may be removed at any time. It is safe for use by multiple goroutines, and must not be copied after first use.

## Get, Put, and New

A Pool is a set of temporary objects that may be individually saved and retrieved.

Get selects an arbitrary item, removes it from the Pool, and returns it.

Get may treat the pool as empty.

Callers should not assume a relation between Put values and later Get values.

When Get would have returned nil and New is set, Get calls New and returns that result.

New optionally specifies a function to generate a value when Get would otherwise return nil.

Put adds x to the pool.

## When a Pool helps, and when it does not

Any item stored in the Pool may be removed automatically at any time without notification.

Several goroutines may use the same Pool at the same time.

A Pool caches allocated but unused items for later reuse. That relieves pressure on the garbage collector.

That makes thread-safe free lists easy to build, but not every free list should use a Pool.

The fmt package is the usual example: it keeps a store of temporary output buffers that grows and shrinks with load.

Do not copy a Pool after you first use it.

## See also

- [go-sync-map](https://iinventedlight.com/library/notes/go-sync-map/)
- [go-sync-mutex](https://iinventedlight.com/library/notes/go-sync-mutex/)
- [go-sync-waitgroup](https://iinventedlight.com/library/notes/go-sync-waitgroup/)

## Claims

- id: C1
  claim: A Pool holds temporary objects that can be saved and retrieved.
  source: S1
  evidence: "temporary objects that may be individually saved"

- id: C2
  claim: Get removes an arbitrary item and returns it.
  source: S1
  evidence: "selects an arbitrary item from the"

- id: C3
  claim: Get may ignore the pool and treat it as empty.
  source: S1
  evidence: "ignore the pool and treat it as empty"

- id: C4
  claim: Put adds a value to the pool.
  source: S1
  evidence: "Put adds x to the pool"

- id: C5
  claim: Stored items may be removed automatically at any time.
  source: S2
  evidence: "removed automatically at any time without"

- id: C6
  claim: A Pool must not be copied after first use.
  source: S2
  evidence: "must not be copied after first use"

## Sources

- [S1] sync package reference. Go. https://pkg.go.dev/sync . License: BSD-3-Clause. Accessed 2026-11-23.

- [S2] sync/pool.go source. Go. https://go.dev/src/sync/pool.go . License: BSD-3-Clause. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, sync package reference; Go, sync/pool.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
