Isn't the code:

if (child != null && child.isDefined()) {
       actor = child.get();
} 

supposed to fetch existing actor actor reference instead of creating a new 
one?

If I call stop() at the end of onReceive() what happens to other instances 
of the same actor which could be processing different vertices? Will they 
be shut down as well?



On Friday, June 10, 2016 at 10:48:48 AM UTC-4, √ wrote:
>
> If you create new actors continually and never stop any of them then you 
> have by design got a leak.
>
> -- 
> Cheers,
> √
> On Jun 10, 2016 4:35 PM, "Mark Kaberman" <mkab...@gmail.com <javascript:>> 
> wrote:
>
>> Hi Viktor,
>>
>> I never stop my actors explicitly (except as reaction to failure in 
>> supervision strategy). All actors process the vertex data in onReceive() 
>> method, determine if a vertex has children, get the children actor by 
>> calling my createActorRef, send the message to a child via tell (never ask) 
>> and exit onReceive.
>>
>> Regards,
>>
>> Mark
>>
>>
>> On Friday, June 10, 2016 at 10:27:25 AM UTC-4, √ wrote:
>>>
>>> Hi Mark,
>>>
>>> Where are you stopping your actors?
>>>
>>> -- 
>>> Cheers,
>>> √
>>> On Jun 10, 2016 2:55 PM, "Mark Kaberman" <mkab...@gmail.com> wrote:
>>>
>>>> I have Akka application which is essentially traverses a very large 
>>>> tree where each vertex processing is done by an individual  actor. 
>>>> Different kinds of vertices are processed by different actors. The actors 
>>>> are implemented as prototype Spring beans (they are derived from the same 
>>>> abstract class) and I am using Akka/Spring integration from Akka 
>>>> Spring integration 
>>>> <https://github.com/typesafehub/activator-akka-java-spring>. The only 
>>>> two differences between the githib example and my code is that I use 
>>>> configuration file to configure the routers and the way I get actor 
>>>> references. 
>>>> Since the example only uses one actor it creates it like 
>>>>
>>>> system.actorOf(SpringExtProvider.get(system).props("CountingActor"), 
>>>> "counter");
>>>>
>>>> My actor system is hierarchical and I create my actors differently
>>>>
>>>> public ActorRef createActorRef(String actorBeanName, String 
>>>> actorRouterName) {
>>>>     ActorRef actor = null;
>>>>     final scala.Option<ActorRef> child = 
>>>> context().child(actorRouterName);
>>>>     if (child != null && child.isDefined()) {
>>>>         actor = child.get();
>>>>     } else {
>>>>         actor = 
>>>> getContext().actorOf(SpringExtProvider.get(system).props(actorBeanName).withRouter(new
>>>>  
>>>> FromConfig()), actorRouterName);
>>>>     }
>>>> }
>>>>
>>>>
>>>> When my system is running for few days it runs out of memory. I ran the 
>>>> profiler and discovered that there is a huge number of actor's Spring 
>>>> beans 
>>>> being instantiated. So I instrumented my actors with the instance counters:
>>>>
>>>> public abstract class MyActor extends UntypedActor {
>>>>
>>>>
>>>>     private static AtomicInteger instantiationCount = new 
>>>> AtomicInteger(0);
>>>>
>>>>     public MyActor() {
>>>>         logger.info("ACTOR CREATED. Instantiation count {}", 
>>>> instantiationCount.getAndIncrement());
>>>>
>>>>     }
>>>>
>>>>     @Override
>>>>     protected void finalize() {
>>>>         logger.info("ACTOR FINALIZED. Instantiation count {}", 
>>>> instantiationCount.getAndDecrement());
>>>>     }
>>>> }
>>>>
>>>>
>>>> When I run  my application I see constant flow of "ACTOR CREATED" log 
>>>> entries with ever incrementing counter with the finalize() method never 
>>>> called. Eventually after few days of running the system runs out of 
>>>> memory. 
>>>> I am wondering if I am doing something wrong with obtaining the actor 
>>>> references or there is some issues with Akka/Spring integration
>>>>
>>>>
>>>> -- 
>>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>>> >>>>>>>>>> Check the FAQ: 
>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>> >>>>>>>>>> Search the archives: 
>>>> https://groups.google.com/group/akka-user
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Akka User List" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to akka-user+...@googlegroups.com.
>>>> To post to this group, send email to akka...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/akka-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to