I. Description
When querying a large amount of data from the database, each template fetches several million pieces of data, or frequently refreshing projects and templates, it will occupy a large amount of memory of the Java Virtual achine JVM. If the memory exceeds the memory, it will be reported to java.lang.OutOfMemoryError: Java heap space memory overflow error, the specific error is as follows:
II. Reason
An error is thrown due to insufficient JVM of the server. The JVM will automatically set the value of heap size when it starts. The initial space (-Xms) is 1/64 of the physical memory, and the maximum space (-Xmx) is the physical memory. 1/4. So you can modify the options such as -Xmn -Xms -Xmx of the JVM according to your own situation.
1. Memory size setting
When the heap size is set too small, in addition to reporting exception information, you will also find that the execution speed of the report becomes slower.
Note: 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. The -Xms -Xmn setting of heap size should not exceed the size of physical memory. Otherwise it will prompt "Error occurred during initialization of VM Could not reserve enough space for object heap"
III.Solutions
1. Increase the memory of the server
For the memory modification of the server, please refer to Modify FineReport configuration parameters.
2. Enable disk caching
We use the memory cache by default, that is, all the retrieved data is placed in the server memory. At this time, if the amount of data is large, it is likely to cause insufficient memory. Change to disk cache, which is to put the retrieved data part in Part of the memory is placed on the disk, which can reduce the server memory usage, but reading data from the disk will cause the efficiency of fetching to decrease and increase the time.
For specific operations, please refer to the section about cache to disk of Data Cache.