0

Sorry, I am a bit new to code development, and this may be a really nonsensical question, but I was just curious to know how much JVM memory is allocated to an object of XSSFWorkbook.

I am developing a JSP-Servlet based application for which I am using excel sheets for input.

For a single user, the application works fine, but for multiple users, getting

java.lang.OutOfMemoryError: Java heap space.

The Java heap space was resolved by setting the Xmx parameter minimum to -Xmx512m though, but I wanted to optimize my code so that the application can be run using even lesser JVM memory space.

I read that for optimal code Apache POI Streaming, SAX- SXSSFWorkbook should be used, but I am not in the position to change the excel code.

Does Garbage Collection work if the object of XSSFWorkbook is closed?

Jérôme
  • 1,254
  • 2
  • 20
  • 25
  • 2
    Of course, that depends on the actual document you are processing, but the general tendency for `XSSFWorkbook` is *lots of them*. We encountered documents that would have consumed several GiB, if we allowed it. So sorry, but it’s possible that not touching the code and just increasing the heap size won’t help. – Holger Jan 22 '18 at 17:59
  • Garbage collection should work if closed but should likely be set to null - also, we've run into issues before and while it's not totally recommended you might try explicitly calling it after any heave resource usage with `System.gc();` – JGlass Jan 23 '18 at 14:54

0 Answers0