Memory leaks while undeploying Akka/Spray application

350 views
Skip to first unread message

Tulio Domingos

unread,
Feb 25, 2014, 4:47:54 AM2/25/14
to akka...@googlegroups.com
When I undeploy my Akka/Spray application, I get the following error in Tomcat: 

Feb 25, 2014 9:27:44 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/spray-template_2.10-0.1] appears to have started a thread named [example-scheduler-1] but has failed to stop it. This is very likely to create a memory leak.
Feb 25, 2014 9:27:44 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/spray-template_2.10-0.1] appears to have started a thread named [example-akka.actor.default-dispatcher-2] but has failed to stop it. This is very likely to create a memory leak.

Looks like there are a couple of threads hanging around in memory..any ideas on how to release them? To make sure it wasn't anything related to my code, I've also used the barebone sample application, but same happens: https://github.com/spray/spray-template

Deploying and undeploying the application a few times will ultimately result in a OOM exception (screenshot attached

system.shutdown, system.awaitTermination, system.stop(serviceActor), serviceActor ! Kill, etc none of that seems to work..any clues??

Using: Tomcat 7, Akka 2.2.3 and 2.3.0-RC3, Spray 1.2.0 and 1.3-RC1

Any help would be much appreciated
Cheers
Tulio


akka_oome.jpg

Akka Team

unread,
Feb 25, 2014, 7:07:01 AM2/25/14
to Akka User List
Hi Tulio,


system.shutdown, system.awaitTermination, system.stop(serviceActor), serviceActor ! Kill, etc none of that seems to work..any clues??

Have you tried

system.shutdown()
system.awaitTermination()

in that order? The first step starts the shutdown asynchronously while the second waits until that finishes. Using awaitTermination alone makes no sense, and using system.shutdown() alone does not do a synchronous shutdown.

-Endre

Using: Tomcat 7, Akka 2.2.3 and 2.3.0-RC3, Spray 1.2.0 and 1.3-RC1

Any help would be much appreciated
Cheers
Tulio


--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> 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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.



--
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

Tulio Domingos

unread,
Feb 25, 2014, 7:33:03 AM2/25/14
to akka...@googlegroups.com
Thanks for the reply Endre, 

Yes, I've tried it on all possible orders...but maybe I had it in the wrong place, I'm calling system.shutdown() and system.awaitTermination() from within the postStop function of class RootServiceActor (that extends HttpServiceActor) Does that make sense?

  override def postStop = {
      system.shutdown()
      system.awaitTermination()
  }


Cheers
Tulio

√iktor Ҡlang

unread,
Feb 25, 2014, 7:36:31 AM2/25/14
to Akka User List
No, it doesn't make sense.
You need to add that in your ServletContextListener
Cheers,

———————
Viktor Klang
Chief Architect - Typesafe

Twitter: @viktorklang

Tulio Domingos

unread,
Feb 25, 2014, 9:55:22 AM2/25/14
to akka...@googlegroups.com
Thanks for the response Viktor! 

Do you mean create my own ServletContextListener (replacing spray.servlet.Initializer in web.xml) with similar implementation but adding system.shutdown() and system.awaitTermination() as part of the contextDestroyed()? I just tried that and seems to work fine now, thanks a lot! Just wondering though, if that's all it was, why isn't this already part of the default behavior in spray.servlet.Initializer?

Cheers
Tulio

√iktor Ҡlang

unread,
Feb 25, 2014, 10:01:44 AM2/25/14
to Akka User List
You're welcome.
As for the behavior of spray.servler.Initializer—I do not know. Ask on spray-user

Tulio Domingos

unread,
Feb 25, 2014, 11:17:50 AM2/25/14
to akka...@googlegroups.com
Will do. Cheers!!
Reply all
Reply to author
Forward
0 new messages