java.lang.OutOfMemoryError: Java heap space

Problem solving one:

eclipse中,window-->preferences-->Java-->Installed JREs

  Select the JRE and  click Edit

Write this sentence :

-Xms800m -Xmx800m -XX:MaxNewSize=256m -XX:MaxPermSize=256m

And set the running jdk of the currently used tomcat to the jdk that has just been set

 

Problem solving two:

  java.lang.OutOfMemoryError: Java heap space solution

The root of this problem is that the default Heap size of the jvm virtual machine is 64M, which can be achieved by setting its maximum and minimum values. There are mainly several ways to set it.

 

1. You can change the system environment variables in Windows

Add JAVA_OPTS=-Xms64m -Xmx512m

 

2, if you use tomcat, under windows, you can

 

Add to C:\tomcat5.5.9\bin\catalina.bat: set JAVA_OPTS=-Xms64m -Xmx256m

 

The location is: rem Guess CATALINA_HOME if not defined Add appropriate below the line.

 

3. If it is a linux system

Linux in front of {tomcat_home}/bin/catalina.sh, add 

set JAVA_OPTS='-Xms64 -Xmx512'

 

 

 

java.lang.OutOfMemoryError: Java heap space 

An exception occurs when querying a large amount of data from the database using a Java program:

java.lang.OutOfMemoryError: Java heap space 

This exception message will be thrown in the JVM if 98% of the time is used for GC and the available Heap size is less than 2%.

 

The setting of the JVM heap refers to the setting of the memory space that the JVM can allocate and use during the running of the java program. The JVM will automatically set the value of the Heap size when it is started, and its initial space (ie -Xms) is 1/64 of the physical memory. The maximum space (-Xmx) is 1/4 of physical memory. It can be set by using options such as -Xmn -Xms -Xmx provided by the JVM.

例如:java -jar -Xmn16m -Xms64m -Xmx128m MyApp.jar

If the Heap Size is set too small, in addition to these abnormal information, the response speed of the program will also be found to be slower. The GC takes more time, and the application is allocated less execution time.

The maximum Heap Size should not exceed 80% of the available physical memory. Generally, the -Xms and -Xmx options should be set to the same, and -Xmn is 1/4 of the -Xmx value.

The -Xms -Xmn setting of Heap size should not exceed the size of physical memory. Otherwise, it will prompt "Error occurred during initialization of VM Could not reserve enough space for object heap".

 

以上办法在我电脑里全都没用。。。
删除工作空间其他项目,删除tomcat下其他项目,全都没用。新建项目只要不加载struts2项目 ,tomcat7能正常启动,如果添加struts2 ,必出现
OutOfMemoryError。重新安装jdk,tomcat,myeclipse照样出现错误,只要删除导入的struts2包就能正常启动。怀疑问题出现在struts2的jar包上,myeclipse默认导入所以jar包,所以试了试只导入核心jar包,没想到成功了。
解决办法:
手工方式只导入以下核心jar包
 
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar
ognl-3.0.jar
freemarker-2.3.16.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
javassist-3.7.ga.jar

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326336706&siteId=291194637