Reduce memory footprint in ActorRef by sharing/caching two Field instances
From user:
I noticed using a memory profiling feature of the VisualVM that akka.Actor creates always two java.lang.reflect.Field objects for each LocalActorRef that it keeps internally for each actor. See http://github.com/jboner/akka/blob/master/akka-actor/src/main/scala/actor/ActorRef.scala for more info. These objects dominate a memory consumption in the Ring benchmark for rings with many e.g. 100000 elements. But this is just an example. Any application that starts a lot of actors of the same class would expose the same effect. I'd say that since these two Field objects are immutable and depend only on the class of the actor, but not on the specific instance, they can be cached and shared between all Actors of the same class. This would save memory and also eventually improve performance as the number of reflection API calls can be reduced.
Leave a comment
on 2010-10-19 07:59 *
By viktorklang
Assigned to set to viktorklang
Milestone changed from 1.0-MILESTONE2 to 1.0-MILESTONE1
Status changed from New to Accepted
PHixed