0

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?

Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154
  • 1
    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! – Marsellus Wallace Sep 18 '12 at 21:49

1 Answers1

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?

Jason Sperske
  • 29,816
  • 8
  • 73
  • 124