3 ms·
It is interesting since in Erlang data structures are functional (immutable) actor mailboxes could as well be implemented to share data instead of copying it. L
by rdtsc 13y ago
It is interesting since in Erlang data structures are functional (immutable) actor mailboxes could as well be implemented to share data instead of copying it. Large binaries are handled that way. They live in a binary memory area and are referenced via pointers. The rest of the messages are not. At some point it was deemed it was better to actually make the copy.
- ANTSANTS 13y agoEven if everything is immutable, sharing data between threads adds memory management overhead that isn't worth it for most objects. For GC, you have to walk the environment of every thread to free anything in the shared memory. I dunno how big of a difference that makes for fancy concurrent GCs, but for regular ones, you'd have to stop every thread during collection. For reference counting, it's a bit simpler; so long as each thread keeps its own reference count, you can decouple the reference counting from freeing and have a hybrid scheme where you "GC" the shared object heap by scanning for objects with reference counts of 0 in all threads. Still not free, though.