IT lexicon › Programming › Shared memory

Shared memory

Programming På svenska → Updated: 2026-07-29

The fastest form of inter-process communication: two processes map the same physical memory pages and read each other's data without copying anything.

The alternatives — pipes, sockets, message queues — go through the kernel and copy at least once. Shared memory costs only a mapping, after which access is as fast as ordinary variables. The price is that you must synchronize yourself: no kernel call protects you, so mutexes or semaphores have to live inside the shared region, and races become your problem. On POSIX systems you use shm_open followed by mmap; on Linux also /dev/shm as ordinary files. Used by databases (PostgreSQL keeps its entire buffer pool here), graphics stacks and shared caches. The older System V variant with shmget lives on but has clumsier lifecycle management.

← Back to the lexicon