?
Solved

Java heap size error

Posted on 2006-05-18
3
Medium Priority
?
674 Views
Last Modified: 2013-11-24
I have created a servlet to upload file. I am running tomcat 4.1.
When I upload the file which is about 100 mb, I got a Java heap space error which I believe created by execute jsp that trigger the servlet.

Can anyone help me where to increase the java heap size? Within the servlet or the tomcat?

Thanks


2006-05-18 07:43:12 WebappLoader[]: Deploying class repositories to work directory C:\Tomcat\work\Standalone\localhost\_
2006-05-18 07:43:12 WebappLoader[]: Deploy class files /WEB-INF/classes to c:\Tomcat\bin\..\webapps\abc\WEB-INF\classes
2006-05-18 07:43:12 WebappLoader[]: Deploy JAR /WEB-INF/lib/jt400Native.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\jt400Native.jar
2006-05-18 07:43:12 WebappLoader[]: Deploy JAR /WEB-INF/lib/mail.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\mail.jar
2006-05-18 07:43:12 WebappLoader[]: Deploy JAR /WEB-INF/lib/ojdbc14.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\ojdbc14.jar
2006-05-18 07:43:12 WebappLoader[]: Deploy JAR /WEB-INF/lib/abc.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\abc.jar
2006-05-18 07:43:12 WebappLoader[]: Reloading checks are enabled for this Context
2006-05-18 07:43:13 StandardManager[]: Seeding random number generator class java.security.SecureRandom
2006-05-18 07:43:13 StandardManager[]: Seeding of random number generator has been completed
2006-05-18 07:43:13 StandardWrapper[:default]: Loading container servlet default
2006-05-18 07:43:13 StandardWrapper[:invoker]: Loading container servlet invoker
2006-05-18 07:44:06 StandardWrapperValve[MyMediaServlet]: Servlet.service() for servlet MyServlet threw exception
javax.servlet.ServletException: Servlet execution threw an exception
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:222)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      at java.lang.Thread.run(Thread.java:595)
----- Root Cause -----
java.lang.OutOfMemoryError: Java heap space

2006-05-18 07:45:25 WebappLoader[]: Deploying class repositories to work directory C:\Tomcat\work\Standalone\localhost\_
2006-05-18 07:45:25 WebappLoader[]: Deploy class files /WEB-INF/classes to c:\Tomcat\bin\..\webapps\abc\WEB-INF\classes
2006-05-18 07:45:25 WebappLoader[]: Deploy JAR /WEB-INF/lib/jt400Native.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\jt400Native.jar
2006-05-18 07:45:25 WebappLoader[]: Deploy JAR /WEB-INF/lib/mail.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\mail.jar
2006-05-18 07:45:25 WebappLoader[]: Deploy JAR /WEB-INF/lib/ojdbc14.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\ojdbc14.jar
2006-05-18 07:45:25 WebappLoader[]: Deploy JAR /WEB-INF/lib/abc.jar to c:\Tomcat\bin\..\webapps\abc\WEB-INF\lib\abc.jar
2006-05-18 07:45:25 WebappLoader[]: Reloading checks are enabled for this Context
2006-05-18 07:45:26 StandardManager[]: Seeding random number generator class java.security.SecureRandom
2006-05-18 07:45:26 StandardManager[]: Seeding of random number generator has been completed
2006-05-18 07:45:26 StandardWrapper[:default]: Loading container servlet default
2006-05-18 07:45:26 StandardWrapper[:invoker]: Loading container servlet invoker
2006-05-18 07:46:07 StandardWrapperValve[MyServlet]: Servlet.service() for servlet MyServlet threw exception
0
Comment
Question by:askJava
  • 2
3 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 16710949
http://web.bvu.edu/staff/david/index.jsp?section=software&subsection=tcservcfg&page=detailed_howto
this program claims to be able to set init heap size for tomcat
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 500 total points
ID: 16711028
another way
in tomcat/bin/catalina.sh
add this line
JAVA_OPTS=-Xmx512m // (or whatever memory you need)
before any other assignment to JAVA_OPTS
0
 

Author Comment

by:askJava
ID: 16713638
Yes I did that b4 the posting. But it didn't fix the problem. I am upload 100mb of ASCI data file to process on the server. I tested the program on Windows b4 moving to UNIX box. On the Windows, I notice the PF usage went all the way up to 1.3 Gig for IE. But when I use Firefox to trigger the program, it only stay around 800 mb. The memory usuage is about 700 mb. To transfer 100mb of data, it needs about 700 mb of memory and 1.3 Gig of PF (Page file)? Also, I notice, the PF stay unchange until I kill the tomcat. Why?

The problem is the data file we receive might be 100 mb or can be 300 mb. It seems like we might have to increase the tomcat heap size to like 1024 or more just to make sure we are on the safe side? It doesn't make any sense?

Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question