jvm configuration

Reason: Common are the following:

1. The amount of data loaded in the memory is too large, such as taking too much data from the database at one time;

2. There is a reference to the object in the collection class, which is not emptied after use, so that the JVM cannot be recycled;

3. There is an infinite loop in the code or the loop produces too many repetitive object entities;

4. BUG in the third-party software used;

5. The memory value of the startup parameter is set too small;

Common error prompts: 1.tomcat:java.lang.OutOfMemoryError: PermGen space

2.tomcat:java.lang.OutOfMemoryError: Java heap space

3.weblogic:Root cause of ServletException java.lang.OutOfMemoryError

4.resin:java.lang.OutOfMemoryError

5.java:java.lang.OutOfMemoryError

 

 

Solution; 1. Solution to the application server prompt error: Set the startup parameter memory value to be large enough.

 

2. The solution of errors caused by Java code: Focus on the following points:

1) Check your code for infinite loops or recursive calls.

2) Check if there is a large loop that repeatedly generates new object entities.

3) Check whether there is a query to obtain all data at one time in the database query. Generally speaking, if 100,000 records are fetched into memory at a time, it may cause memory overflow. This problem is relatively hidden. Before going online, there is less data in the database, and it is not easy to cause problems. After going online, there is a lot of data in the database, and a single query may cause memory overflow. Therefore, for database queries, try to use paging methods to query.

4) Check whether the collection objects such as List and MAP are not cleared after use. Collection objects such as List and MAP will always have references to objects, so that these objects cannot be recycled by GC.

Case: 1. When hibernate queried data, it queried too much data at one time, and then adjusted the code of this part, and only took out the specified amount of data each time, which successfully solved the problem. 2. During the stress test, an OutOfMemoryError occurs, and it is found that the resources of the session have not been released. It is best to release the resources of the session through the invalidate() method of the session. 3. An infinite loop occurs in the program. 4. OutOfMemoryError occurs during tomcat deployment and operation, increase the memory parameter value to solve this problem.

 

 

 

 

java.lang.OutOfMemoryError: Java heap space exception handling in tomcat

1. Heap size 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 starts, and its initial space (ie -Xms) is the physical memory. 1/64, the maximum space (-Xmx) is 1/4 of the physical memory. It can be set by using options such as -Xmn -Xms -Xmx provided by the JVM. The size of Heap size is the sum of Young Generation and Tenured Generation. Hint: This exception will be thrown if 98% of the time in the JVM is used for GC and the available Heap size is less than 2%. Tip: 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.

2. Solution: Manually set the Heap size Modify TOMCAT_HOME/bin/catalina.sh Add the following line above "echo "Using CATALINA_BASE: $CATALINA_BASE"": JAVA_OPTS="-server -Xms800m -Xmx800m -XX:MaxNewSize=256m"

 

 

java.lang.OutOfMemoryError: PermGen space exception handling in tomcat

1. PermGen space The full name of PermGen space is Permanent Generation space, which refers to the permanent storage area of ​​memory. This memory is mainly used by JVM to store Class and Meta information. When Class is loaded by Loader, it will be placed in PermGen space. Unlike the Heap area that stores class instances (Instance), GC (Garbage Collection) does not clean up the PermGen space during the main program runtime, so if there are many CLASS in your application, PermGen space errors are likely to occur. This kind of error is common when the web server precompiles the JSP. If your WEB APP uses a large number of third-party jars, the size of which exceeds the default size of jvm (4M), then this error message will be generated.

Solution: Manually set MaxPermSize size Modify TOMCAT_HOME/bin/catalina.sh Add the following line above "echo "Using CATALINA_BASE: $CATALINA_BASE"": JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m Suggestion: Move the same third-party jar file to the tomcat/shared/lib directory, so as to reduce the memory occupied by the jar file repeatedly.

 

 

java.lang.OutOfMemoryError exception handling in weblogic

Error message: "Root cause of ervletException java.lang.OutOfMemoryError"

解决办法: 调整bea/weblogic/common中CommEnv中参数    :sun   if "%PRODUCTION_MODE%" == "true" goto sun_prod_mode   set JAVA_VM=-client   set MEM_ARGS=-Xms256m -Xmx512m -XX:MaxPermSize=256m   set JAVA_OPTIONS=%JAVA_OPTIONS% -Xverify:none   goto continue   :sun_prod_mode   set JAVA_VM=-server   set MEM_ARGS=-Xms256m -Xmx512m -XX:MaxPermSize=256m   goto continue

 

 

 

 

 

java.lang.OutOfMemoryError : PermGen space exception handling when Eclipse runs Jboss

When running Jboss in Eclipse, if the time is too long, an error of java.lang.OutOfMemoryError: PermGen space may sometimes appear. Here is a solution:

1) Click the small arrow next to the debug icon;

2) Click the "Debug Configurations..." menu item;

3) Select "JBoss v4.2 at localhost" under the "Generic Server" tree on the left;

4) Click the "Arguments" tab on the right, and add in "VM arguments":

-Dprogram.name=run.bat -Djava.endorsed.dirs="D:/JBoss405/bin/../lib/endorsed" -Xms128m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=256m

5) If you are running JBoss in command line mode or directly by clicking "run.bat", then you need to modify the JVM options in the bin/run.conf file and find JAVA_OPTS="-Xms128m -Xmx512m..." This paragraph, then add "-XX:PermSize=64m -XX:MaxPermSize=256m" after it. Save is OK.

6) Note: The numbers 128, 512, 64 and 256 can be adjusted according to the configuration of your own machine, and then click "Apply".

 

 

java.lang.OutOfMemoryError exception handling under Resin

Reason: This error occurs, generally because the JVM physical memory is too small. The default maximum memory of the Java virtual machine is only 64 megabytes, which may be no problem during development and debugging, but it is far from enough in the actual application environment, unless your application is very small and has little access. Otherwise you may find errors in the package java.lang.OutOfMemoryError after the program runs for a while. Therefore we need to increase the size of the virtual machine memory available to resin.

Solution: Modify the args option in /usr/local/resin/bin/httpd.sh to add parameters -Xms (initial memory) and -Xmx (maximum memory size that can be used), which can be used to limit the physical memory usage of the JVM. For example: args="-Xms128m -Xmx256m" After setting, the initial physical memory of the JVM is 128m, and the maximum physical memory that can be used is 256m. These two values ​​should be set by the system administrator according to the actual situation of the server.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326564003&siteId=291194637