Memory Overflow Solutions

Memory overflow problem-solving ideas

 

This article said that under Solutions, of course, write the corresponding business background. Intention of it, one would like to record Problem Procedure, as later experience; two of it, for everyone to share, you can learn to listen to the next story.

it has started.

 

Project error What is wrong with it?

  java.lang.OutOfMemoryError: Java heap space

  java.lang.OutOfMemoryError: GC overhead limit exceeded 

 

Error business functions are:

  Export data encryption EXCEL documents.

  That is the 10 million data read from the database out into excel table, it is placed in memory, the table is encrypted, and returns the file stream.

 

At that time the background:

  Local idea to run no problem, but deployed to the server memory overflow occurs above ERROR .

 

So my analysis:

  A direction: the program code in question, object creation too. 10 million rows * 5 column = 50 million cells objects, may be more. So by way paging query data, 10 million data is divided into 20 times, that each query 5000 pieces of data in batches into the sheet object. However, this does nothing with eggs.

 

  Direction II: to JVM expansion. The original startup parameters -Xms256M -Xmx512M , expanded to 768 and 1024 , so the issue is resolved, do not report memory overflow.

      but! A temporary solution, the memory of this program is to expand, but there are other procedures that may affect the normal use.

      Then again Baidu search various " POI memory overflow problem", and finally he found the root cause of a memory overflow. It turned out that I use the POI version is too low, the high version of the POI has solved the problem of memory overflow, that is, by defining clear memory of the memory reach a certain number of lines the way.

 

  Had been Baidu keyword used either "java.lang.OutOfMemoryError", either "GC overhead limit exceeded Number of ", while another keyword " POI memory overflow" to search for the answer has long been the senior po out.

 

To sum up , a problem, and many consider to be the cause, then a possible specific reasons to Baidu search, or like a needle in a haystack.

 

Guess you like

Origin www.cnblogs.com/one-gril/p/11614237.html