Reference: http://baike.baidu.com/view/79183.htm
Memory OverflowIt refers to the memory in the application system that cannot be recycled or that is used too much, so that the memory used by the program is greater than the maximum memory available by the virtual machine.
Memory OverflowCauseThere are many common types:
1. The amount of data loaded in the memory is too large, such as extracting too much data from the database at a time;
2. There are references to objects in the Collection class, which are not cleared after use, so that JVM cannot be recycled;
3. There are endless loops or loops in the code that generate too many repeated object entities;
4. Bugs in third-party software used;
5. The memory value of the startup parameter is set too small;
Memory OverflowSolution:
Step 1Modify the JVM startup parameters to directly increase the memory size. (Do not forget to add the-XMS and-xmx parameters .)
Step 2Check the error log and check whether there are other exceptions or errors before the "outofmemory" error.
Step 3To check and analyze the code to find out where memory overflow may occur.
Troubleshoot the following issues:
1. check whether all data is obtained once in the database query. Generally, if 100,000 records are retrieved to the memory at a time, memory overflow may occur. This problem is relatively hidden. Before going online, the database has less data and is not prone to problems. After going online, there is more data in the database, and a single query may cause memory overflow. Therefore, we recommend that you query the database by page.
2. check whether there is an endless loop or recursive call in the code.
3. check whether there are large loops that repeatedly generate new object entities.
4. check whether all data is obtained once in the database query. Generally, if 100,000 records are retrieved to the memory at a time, memory overflow may occur. This problem is relatively hidden. Before going online, the database has less data and is not prone to problems. After going online, there is more data in the database, and a single query may cause memory overflow. Therefore, we recommend that you query the database by page.
5. Check whether list, map, and other collection objects are not cleared after use. List, map, and other collection objects always have references to objects, so that these objects cannot be recycled by GC.
Step 4, Use the memory viewing tool to dynamically view memory usage.