Profile Image
laxmanpadamati6

Huge unwanted memory usage

I am using apache poi in my application. is it the reason for the high memory usage. once i hit the api even after sending the response memory is not being released.


Report URL - https://gceasy.io/my-gc-report.jsp?p=c2hhcmVkLzIwMjUvMDMvMjYvZ2MubG9nLS04LTM2LTMz&channel=WEB

    Please Sign In or to post your comment or answer

    Profile Image

    Kousika M

    Hello Laxmanpadamati6,

    Greetings!

     

    High memory usage when using Apache POI may occur, especially if you're working with large Excel files. POI stores data in memory, which can lead to increased memory consumption. If memory is not being released even after the response is sent, here are a few possible reasons and suggestions to investigate:

    You can check if all POI objects like Workbook, Sheet, or Cell are properly closed using workbook.close(). If these objects are still referenced, memory will remain occupied.

    Check for memory leak. Perform a heap dump analysis using tools like HeapHero, Eclipse MAT to identify memory leaks. Apache POI objects could be retained if not managed correctly.

    If suppose the GC isn’t triggered immediately, memory may appear unreleased. Monitor the GC logs to check if frequent GC pauses or memory pressure are occurring.

    Additionally, if you’re processing large files, consider using SXSSFWorkbook instead of XSSFWorkbook. It uses a streaming API that writes data to disk instead of holding it in memory, significantly reducing memory consumption.

     

    Ensure all input/output streams are closed using try-with-resources or finally blocks to prevent memory from being unnecessarily held.

    Thanks.

    Got something else on mind? Post Your Question