← All notes

Python multiprocessing.shared_memory: share a memory block across processes

Answer: This module provides a SharedMemory class for allocating and managing shared memory that processes can access.

What this module means by shared memory

In this module, shared memory refers to POSIX style shared memory blocks, not to distributed shared memory.

Distinct processes can read and write a common region of volatile memory.

Each shared memory block is assigned a unique name.

SharedMemoryManager, a BaseManager subclass in multiprocessing.managers, helps manage the life cycle across processes.

Starting a manager and cleaning up

Calling start on a SharedMemoryManager instance starts a new process.

Calling shutdown on that instance releases the blocks the process manages.

Use unlink when you need to delete the underlying shared memory block.

ShareableList offers a list-like view of shared memory, with a known issue for bytes and str values.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, multiprocessing.shared_memory — Shared memory for direct access across processes; CPython, multiprocessing.shared_memory documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, multiprocessing.shared_memory — Shared memory for direct access across processes; CPython, multiprocessing.shared_memory documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:1xzs87hs

iinventedlight. 2026. "Python multiprocessing.shared_memory: share a memory block across processes." iinventedlight Library, iil:note:1xzs87hs, version of 2026-11-26. https://iinventedlight.com/library/notes/python-shared-memory/. License: CC-BY-4.0.

@misc{iil_note_1xzs87hs,
  author = {{iinventedlight}},
  title = {{Python multiprocessing.shared\_memory: share a memory block across processes}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/python-shared-memory/},
  note = {Permanent ID iil:note:1xzs87hs. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-shared-memory.md.