akka – Shared immutable state between actors


What are the drawbacks of sharing immutable state between actors in a non-clustered system?

It’s clear as to why a mutable shared state works against a lot of the guarantees that the actor model provides, but what if that state is immutable? In our case, we have a large dataset which needs to be readily available in memory in order for us to perform operations on it (it’s a complex graph which needs to be traversed). For every actor to hydrate the dataset from persistence and hold onto their own copy in memory is quite expensive. A solution to this is to inject a single instance of this data into each actor, thus having them use the same memory space.

Why might it be considered an anti-pattern for actors to share memory objects on the heap?