Take the 2-minute tour ×

I have a function that loads several serialized objects from the file system by using Java 5 FutureTask. My computer memory should not be an issue.

If I call the function within a main method everything works fine but if I call the function from within the init() or in a static block of a HTTPServlet I get all kinds of OutOfMemoryException (usually Java heap space)...

Does anyone know why by using a Servlet I end up hitting this issue? Can FutureTasks and Servlets conflict in any way and what can I do to understand/fix the issue?

share|improve this question
What application server are you using? Look at the server startup script. What is the value given to the Xmx setting? –  Rajesh J Advani Sep 18 '12 at 21:40
Rajesh, you nailed it! It had nothing to do with FutureTask. By the way, I'm using the maven jetty plugin and I just changed the MAVEN_OPTS environmental variable. The standalone app had the right configuration while maven did not. Thanks! –  Gevorg Sep 18 '12 at 21:49

1 Answer 1

Well your computer memory and your JVM memory can be very different things (out of the box the JVM only allocates 64Mb of RAM (depends on the JVM). However without some concrete code or example data size it's hard to know exactly what is the problem in your case. HTTPServlet is not marked as non thread-safe. Can you provide any code that illustrates your problem?

share|improve this answer
Jason, it was an issue with different Xmx configuration of IntelliJ and Maven, thanks –  Gevorg Oct 5 '12 at 12:20

Your Answer


