Yaroslav,

Under what condition would the single actor in your test program be 
terminated. The Terminated message is only sent when the actor is 
terminated but I see in your code no possibility of the actor ever being 
terminated.

On Monday, March 30, 2015 at 12:40:37 AM UTC-4, Yaroslav Klymko wrote:
>
> Hi Reid, 
> I opened an issue on github regarding this: 
> https://github.com/akka/akka/issues/17087
> The problem as I can see it is in the no Terminated messages sent by 
> PromiseActorRef, thus these actor get watched forever and not collected by 
> gc.
>
> On Monday, March 30, 2015 at 12:53:35 AM UTC+3, Reid Spencer wrote:
>>
>> Yaroslav,
>>
>> The ask pattern doesn't execute synchronously but returns a Future[Any] 
>> immediately, which your program is ignoring.  The future captures the 
>> response from the actor at some future time (when the message send/reply is 
>> complete). However, in your main program, that infinite loop is going to 
>> many of those Future[Any] responses very quickly which will eventually 
>> exhaust memory or overflow the message buffer. All those created future 
>> objects aren't leaks per se as much as they are being created so fast that 
>> the garbage collector has trouble keeping up with it. 
>>
>> If you wanted to make those calls synchronous, you should use the 
>> Await.result idiom by changing the loop to:
>>
>> while (true) {
>>   val future = actor ? "Request"
>>   val result = Await.result(future, timeout.duration)
>>   assert(result == "Response")
>> }
>>
>>
>> Hope that helps.
>>
>> Reid.
>>
>> On Sunday, March 29, 2015 at 5:04:50 AM UTC-4, Yaroslav Klymko wrote:
>>>
>>> The minimal app to reproduce this:
>>>
>>> import akka.actor.{Actor, ActorSystem, Props}
>>> import akka.pattern.ask
>>> import akka.util.Timeout
>>> import scala.concurrent.duration._
>>>
>>> object MemoryLeakApp extends App {
>>>   val system = ActorSystem()
>>>   val actor = system.actorOf(Props[MyActor])
>>>   implicit val timeout = Timeout(3.seconds)
>>>   while (true) {
>>>     actor ? "Request"
>>>   }
>>> }
>>>
>>> class MyActor extends Actor {
>>>   def receive = {
>>>     case _ =>
>>>       val actor = sender()
>>>       context.watch(actor)
>>>       actor ! "Response"
>>>   }
>>> }
>>>
>>>
>>> On Sunday, March 29, 2015 at 12:03:43 PM UTC+3, Yaroslav Klymko wrote:
>>>>
>>>> Hi guys,
>>>> Root cause of my issue has been found, in short it is caused by *context 
>>>> watch sender()*, where the sender is PrmiseActorRef.
>>>>
>>>>
>>>> On Sunday, March 29, 2015 at 10:33:47 AM UTC+3, Yaroslav Klymko wrote:
>>>>>
>>>>> So PrmiseActorRef is leaking and keeps reference on Promise & 
>>>>> WriteEventsCompleted, still I'm not able to find a combination of 
>>>>> dispatchers/actors to reproduce on simple example.
>>>>>
>>>>> On Saturday, March 28, 2015 at 9:33:15 PM UTC+2, Yaroslav Klymko wrote:
>>>>>>
>>>>>> Hi guys,
>>>>>> I have a very strange problem, it was originally spotted by 
>>>>>> @gfduszynski
>>>>>> https://github.com/EventStore/EventStore.Akka.Persistence/issues/11
>>>>>>
>>>>>> Here is a problematic line of code 
>>>>>>
>>>>>> https://github.com/EventStore/EventStore.Akka.Persistence/blob/v2.0.0/src/main/scala/akka/persistence/eventstore/journal/EventStoreJournal.scala#L28
>>>>>>
>>>>>> Basically it is a *actor ? WriteEvents* which returns 
>>>>>> *Future[WriteEventsCompleted]*, these *WriteEventsCompleted* messages 
>>>>>> are leaking, however *actor ! WriteEvents *is not leaking...
>>>>>> Also I couldn't reproduce this using simple app without akka 
>>>>>> persistence.
>>>>>>
>>>>>>  I will really appreciate any help, any ideas.
>>>>>> Thanks!
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <https://lh3.googleusercontent.com/-GswiQ2lLtTU/VRcAmBy7mDI/AAAAAAAAMHE/0fjbSplbpK4/s1600/Screenshot%2Bat%2BMar%2B28%2B21-26-50.png>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <https://lh3.googleusercontent.com/-iBvp3mltxVs/VRcArTBLSpI/AAAAAAAAMHM/1E9raW_PKnI/s1600/Screenshot%2Bat%2BMar%2B28%2B21-26-35.png>
>>>>>>
>>>>>>
>>>>>>
>>>>>>

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to