Jeril Nadar Jeril Nadar - 18 days ago 6
Java Question

How to free up the memory from a Apache POI workbook once the task is over?

I have opened a large excel file as a Apache POI workbook (using VM args to set max memory size)

After successfully opening the file, I read the required data and finished my work.

Now I want to continue further in the programming with other tasks but before I do that I want to make sure I free up the memory used up the workbook.

I checked the API doc but there is nothing like workbook.close().

Can someone suggest what's the right way to free up the memory taken up by the workbook?


I believe you just need to let the objects go out of scope and let the GC do its work. You might also want to consider using the streaming POI framework since that uses less memory.

Streaming Workbook