What does the memory overflow mean?

Source: Internet
Author: User

  There are a number of reasons for the memory overflow, and the small series enumerates the following common types:

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

2. The collection class has a reference to the object, not emptied after use, so that the JVM can not be recycled;

3. Object entities in the code that have dead loops or loops that produce too many duplicates;

4. Bugs in third party software used;

5. Startup parameter memory value set too small

  Memory Overflow Solution:

The first step is to modify the JVM startup parameters to increase memory directly. (-XMS,-XMX parameter must not forget to add.) )

In the second step, check the error log to see if there are any other exceptions or errors before the "OutOfMemory" error.

The third step is to check and analyze the code to find out where the memory overflow may occur.

 Focus on the following points:

1. Check whether there is a query in the database query that gets all the data. In general, if you take 100,000 records to memory at a time, it can cause a memory overflow. This problem is more covert, before the line, the data in the database is less, not easy to problem, online, the database more data, a query may cause memory overflow. Therefore, the database query as far as possible in the way of paging query.

2. Check to see if there is a dead loop or recursive call in the code.

3. Check if there is a recurring cycle to produce new object entities.

4. Check whether there is a query in the database query that gets all the data. In general, if you take 100,000 records to memory at a time, it can cause a memory overflow. This problem is more covert, before the line, the data in the database is less, not easy to problem, online, the database more data, a query may cause memory overflow. Therefore, the database query as far as possible in the way of paging query.

5. Check the list, map and other collection objects have been used after the problem has not been cleared. Collection objects such as List and map always have references to objects so that they cannot be reclaimed by GC.

Step fourth, use the memory viewing tool to dynamically view memory usage

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.