4 ms·
So, does that mean it's safe to say that Erlang must copy the memory of values sent as messages between processes? Or, is there some kind of locking of such (a
by Roboprog 13y ago
So, does that mean it's safe to say that Erlang must copy the memory of values sent as messages between processes? Or, is there some kind of locking of such (aliased) message data???
- voidlogic 13y agoI would think so unless it stores all message bodies in shared memory and protects them with an enforced COW policy to begin with, or better yet does this with virtual memory with some clever COW mmapping.
- JulianMorrison 13y agoMessages are deep-copied in Erlang. There are other techniques possible such as uniqueness types, which allow "transfer of ownership", Rust uses those but Erlang does not.
- lpgauth 13y agoThat's not exactly true... in Erlang, any binary with size > 64 bytes will not be copied. Instead a pointer to a shared memory area will be passed.
- cpeterso 13y agoIf pointers are sent between Erlang processes, how does the per-process GC work without stopping the world?
- JulianMorrison 13y agoBig binaries (which yeah, I forgot about) live off to the side and are not GC'd. They're ref counted.
- masklinn 13y ago> So, does that mean it's safe to say that Erlang must copy the memory of values sent as messages between processes? Theoretically not since Erlang data structures are immutable, but outside of binaries which seat in a shared global heap the benefits was never considered to outweight the complexity costs (aliasing analysis and others), so messages are copied indeed.