Java.lang.OutOfMemoryError Handling Errors

Source: Internet
Author: User
Tags jboss xms

Java.lang.OutOfMemoryError Exception resolution Method

Cause: The following are common:

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

2. There are references to objects in the collection class that are not emptied after use, so that the JVM cannot be recycled;

3. There are dead loops or loops in the code that produce too many duplicate object entities;

4. Bugs in the use of third-party software;

5. Startup parameter memory value setting is too small;

Common error Hints:

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. Application Server Prompt Error Resolution: Set the boot parameter memory value is large enough.

2.Java code leads to error resolution: Focus on troubleshooting the following points:

1) Check the code for a dead loop or recursive call.

2) Check if there are cycle duplicates of the new object entity.

3) Check whether there is a query in the database query that gets all the data at once. In general, if you take 100,000 records to memory at a time, you can cause a memory overflow. This problem is more covert, before the online, the database less data, not prone to problems, on-line, the database more data, a query may cause memory overflow. Therefore, query the database query as much as possible by paging.

4) Check whether the list, map, and other collection objects are not cleared after use. Collection objects such as List, map, and so on will always have a reference to the object so that they cannot be reclaimed by GC.

Case: 1.hibernate query data, one query too much data, and then adjusted the part of the code, each time only to remove the specified amount of data, successfully solve the problem. 2. In the stress test, there is outofmemoryerror, found that the session resources have not been released, preferably through the session of the Invalidate () method to release the session resources. 3. There is a dead loop in the program. 4.tomcat deploy, run OutOfMemoryError, increase memory parameter value, resolve this problem.

Tomcat Central Java.lang.OutOfMemoryError:Java Heap Space Exception Handling

The heap size JVM stack is set to the amount of memory space that the JVM can provision during the run of the Java program. The JVM automatically sets the value of the Heap size when it starts, and its initial space (that is,-XMS) is 1/64 of the physical memory, the maximum space (-XMX) is 1/4 of the physical memory. You can use options such as the-XMN-XMS-XMX provided by the JVM to set it up. The size of Heap size is the sum of young Generation and tenured generaion. Tip: This exception message is thrown in the JVM if 98% of the time is used for GC and the available heap size is less than 2%. Tip: The Heap Size does not exceed 80% of the available physical memory, generally the-XMS and-XMX options are set to the same, and the-XMX value of-xmn is 1/4.

Ii. Workaround: Manually set the heap size to modify tomcat_home/bin/catalina.sh in the "echo" Using catalina_base: $CATALINA _base "" Add the following line above: java_opts= "- server-xms800m-xmx800m-xx:maxnewsize=256m "

Tomcat Zhong Java.lang.OutOfMemoryError:PermGen Space Exception Handling

First, PermGen space PermGen space is the full name of permanent Generation space, refers to the memory of the permanent storage area, this block of memory is mainly stored by the JVM class and meta information, Class is placed in PermGen space when it is loader, unlike the heap area where the class instance (Instance) is stored, the GC (garbage Collection) does not clean up permgen space during the main program run time. So if you have a lot of classes in your application, you are likely to have PermGen space errors, which are common when the Web server pre-compile the JSP. If you have a large number of third-party jars under your web app that are larger than the JVM's default size (4M), this error message will be generated.

Workaround: Manually set the MaxPermSize size modification tomcat_home/bin/catalina.sh on the "echo" Using catalina_base: $CATALINA _base "" Add the following line: java_opts = "-server-xx:permsize=64m-xx:maxpermsize=128m Recommendation: The same third-party jar file is moved to the Tomcat/shared/lib directory, which reduces the memory consumption of the jar document."

WebLogic Zhong Java.lang.OutOfMemoryError Exception Handling

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

Workaround: Adjust commenv parameters in Bea/weblogic/common: 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

Eclipse Run JBoss when Java.lang.OutOfMemoryError : PermGen space Exception Handling

When running JBoss in eclipse, too much time may sometimes occur with Java.lang.OutOfMemoryError:PermGen space error, here is a solution to introduce you:

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

2) Click on the "Debug configurations ..." menu item;

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

4) Click on the "Arguments" tab on the right and add it to "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 by clicking "Run.bat" directly, you will need to modify the JVM options in the bin/run.conf file to find java_opts= "-xms128m-xmx512m ..." This paragraph, and then add "-xx:permsize=64m-xx:maxpermsize=256m" in the back. Save is OK.

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

Resin Next Java.lang.OutOfMemoryError Exception Handling

Cause: This error usually occurs because the JVM is too small in physical memory. The default Java virtual machine has a maximum memory of only 64 trillion, which may not be a problem during the development and debugging process, but is far from sufficient in the actual application environment, unless your application is very small and has little traffic. Otherwise you may find that the program is running for a period of time after the package Java.lang.OutOfMemoryError error. So we need to increase the size of the virtual machine memory available to resin.

FIX: Modifying the args option in/usr/local/resin/bin/httpd.sh adds parameter-xms (initial memory) and-XMX (maximum memory size) can be used to limit the amount of physical memory used by the JVM. For example: After the args= "-xms128m-xmx256m" setting, the JVM's initial physical memory is 128m and the maximum physical memory used is 256m. These two values should be set by the system administrator based on the actual situation of the server.

Java.lang.OutOfMemoryError Handling Errors

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.