A deep copy recursively duplicates a value’s complete hierarchy, so processes can exchange data without sharing memory. In BEAM, sending a message or closing over a variable for a spawned process copies the relevant terms. section 5.2.1 section 5.4.3
Treat deep copying as an operational boundary with practical performance consequences:
- Preserves process isolation: the receiving process cannot directly alter the sender’s internal data. section 5.4.3
- Copies nested structures in memory; occasional large messages may be acceptable, while frequent transfers of complex data can reduce performance. section 5.4.3
- Uses reference copying for binaries larger than 64 bytes, literals, and terms created through :persistent_term. section 5.4.3
- Returns snapshots when data crosses an ETS boundary, even though ETS tables themselves are mutable and shared among processes. section 10.3.1
Passing data into a spawned process
A closure such as spawn(fn -> some_fun(data) end) deep-copies data into the new process. Likewise, send(target_pid, data) copies the message contents, allowing the processes to continue independently. section 5.4.3
data = ... spawn(fn -> ... some_fun(data) #1 ... end)
Inspect how a value captured by a spawned function crosses the process boundary. section 5.4.3




