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
- id: C1 claim: Each shared memory block is given a unique name. source: S1 evidence: "Each shared memory block is assigned a unique name."
- id: C2 claim: Starting a SharedMemoryManager starts a new process. source: S1 evidence: "A call to start() on a SharedMemoryManager instance causes a new process to be started."
- id: C3 claim: The object remains the same shared object. source: S2 evidence: "Note, that it will still be the same shared object."
- id: C4 claim: Use unlink to delete the underlying shared memory block. source: S1 evidence: "Delete the underlying shared memory block"
Sources
- [S1] multiprocessing.shared_memory — Shared memory for direct access across processes. Python Software Foundation. https://docs.python.org/3/library/multiprocessing.shared_memory.html . License: PSF License Version 2. Accessed 2026-11-26.
- [S2] multiprocessing.shared_memory documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/multiprocessing.shared_memory.rst . License: PSF License Version 2. Accessed 2026-11-26.
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
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.},
}
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.
- python-shared-memory.schema.json (schema; CC-BY-4.0)
- python-shared-memory.table.json (table; CC-BY-4.0)
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.