FineReport memory mechanism

  • Last update:July 08, 2022
  • I. Overview

    In the process of using the report, sometimes you will encounter the problem of memory overflow. The following briefly introduces the memory mechanism of our report and how to release the memory.

    II. Memory mechanism

    1. Java memory recycling mechanism

    Java's memory garbage collection (GC) mechanism is to check the reference chain from the main running object of the program, and after traversing it again, it is found that the isolated objects that are not referenced are collected as garbage. In order for the GC to release objects correctly, it must monitor the running status of each object. Including the application, quotation, reference, assignment, etc. of objects, GC needs to be monitored.

    In Java, these useless objects are collected by the GC. At the same time, Java provides functions to access the GC, such as the function System.GC() to run the GC, but according to the Java language specification, this function does not guarantee the garbage collector of the JVM It will definitely be executed. Because different JVM implementors may use different algorithms to manage GC. Generally, the priority of GC threads is lower. There are also many strategies for JVM to call GC. Some are that the GC only starts to work when the memory usage reaches a certain level, some are executed regularly, some are gentle execution of GC, and some are interrupted execution of GC.

    The main reason for the memory leak is that the memory space was previously applied for and forgot to release it. If there are references to useless objects in the program, these objects will reside in memory and consume memory, because the garbage collector GC cannot verify whether these objects are no longer needed. If there is a reference to an object, the object is defined as a "valid activity" and will not be released. To determine that the memory occupied by an object will be recycled, we must confirm that the object will no longer be used.


    2. Description of the memory management release mechanism in FineReport

    The backend of FineReport report is written in pure Java language, so its memory release mechanism is consistent with the above. When the interaction between the client and the server ends (such as closing the browser page, printing ends, etc.), the server will consume the previous client operations. The memory of it is released, that is, set to be reclaimable state, waiting for JVM to call GC.

    III. Manual GC method in FineReport

    The critical point of FineReport under 1G memory should be about 130w rows*5 columns. For some integrated environments, it may be necessary to do some operations to release the memory occupied by FR, and FR also provides a response for interface, the specific usage method is as follows:

    Add a button to a widget, add a click event to the button, or call it directly in JS, the content is as follows:

    $.ajax({
         url : FR.servletURL,
         data : {
              op : 'fr_utils',
             cmd : 'gs_gc'
              },
         async : false,
    })

    Keyword: GC

    Attachment List


    Theme: Performance Optimization
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy