5

I'm developing web application in jsp/servlet,i had an issue with netbeans and Java. My program needs large data process. So I used -Xmx512m to increase the maximum heap size via

Tools -> Servers -> on the Platform tab there is a VM option below Java Platform. Then it works fine..

Now my issue is i'm building the WAR file, directly deployed and run in my another machine Tomcat for demo, here i'm facing the same issue java out of memory error-heap space i also tried with

environment variable set CATALINA_OPTS=-Xms512m -Xmx512m

this also didn't help me

how to resolve this issue?, Please point me to the right direction

3
  • 1
    Make it -Xmx1024m and try again. Commented Sep 11, 2012 at 9:49
  • where in the environment variable? Commented Sep 11, 2012 at 9:50
  • Finally i found the solution for the issue see my answer below Commented Sep 11, 2012 at 11:15

5 Answers 5

11

Try to set PermSizeand MaxPermSize values and that should be set at tomcat startup in Catalina.bat and then stop and start using this script.

  set CATALINA_OPTS=-server -Xms1024m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m

http://javahowto.blogspot.co.uk/2006/06/6-common-errors-in-setting-java-heap.html

Sign up to request clarification or add additional context in comments.

11 Comments

@Sathish which env are you using ? Window or Unix ?
in Catalina.bat which line i need to add that
@duffymo did you see the Catalina.bat file there are many line are there .. thats y i asked
Where you have set CATALINA_OPTS= . you have to update this line.
@Sathish - yes, but they don't all set CATALINA_OPTS.
|
8

Finally i found the solution for the issue

in Catalina.bat file you can find some text like below

set _EXECJAVA=%_RUNJAVA%
set MAINCLASS=org.apache.catalina.startup.Bootstrap
set ACTION=start
set SECURITY_POLICY_FILE=
set DEBUG_OPTS=
set JPDA=

under that you need to put the

set CATALINA_OPTS=-Xms512m -Xmx512m

Heap size is larger than your computer's physical memory. For example,

java -Xmx2g BigApp Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.

The fix is to make it lower than the physical memory: java -Xmx1g BigApp

Comments

2

I know I am totally late on this reply but in case it would be helpful to anybody runs into the same situation I think it worth to put a note here. I am referring to tomcat 9 so you might need to check how things mentioned here are relevant to your version:

In %CATALINA_HOME%/bin/catalina.bat, it clearly stated that:

rem   WHEN RUNNING TOMCAT AS A WINDOWS SERVICE:
rem   Note that the environment variables that affect the behavior of this
rem   script will have no effect at all on Windows Services. As such, any
rem   local customizations made in a CATALINA_BASE/bin/setenv.bat script
rem   will also have no effect on Tomcat when launched as a Windows Service.
rem   The configuration that controls Windows Services is stored in the Windows
rem   Registry, and is most conveniently maintained using the "tomcatXw.exe"
rem   maintenance utility, where "X" is the major version of Tomcat you are
rem   running.

If you check your %CATALINA_HOME%/bin folder, you could find a file named like "tomcat9w.exe". Double click on it and you could see this screen shot where you can set your Xms and Xmx parameters for it to save into registry for you

Hope this helps

Comments

0

Out of memory error can be result of big session-timeout number in Tomcat's web.xml. In that case many web sessions can take many system memory.

Comments

-1

I suggest you enable heap dump and analyze using IBM support Workbench (which has heap dump analyzers) and understand the problem exactly and make configurations accordingly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.