java out of memory error-heap space

帅比萌擦擦* 提交于 2019-12-04 09:48:38
amicngh

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

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

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!