'Why am I still getting OOM errors with Apache POI using SXSSFWorkbook?
We were using the XSSFWorkbook class to build an excel report, but began getting OOM errors as the included data increased. I've updated the code to make use of the SXSSFWorkbook class instead as I read it is much lighter on memory as data is 'flushed to disk' rather than being stored in memory.
I am able to add all of the data to the workbook but when trying to write the data to a file (OutputStream) I am getting Java heap space errors once again. I'm not sure if I am doing something wrong here, I'm not sure I understand what is meant the records being 'flushed to disk'. Should I be providing a file reference before loading the data into the workbook so it can be flushed to the actual file? Or should I be doing something else when writing the workbook to the output stream?
I've done some testing and it seems I only get the OOM error when setting styles on the cells, if I forgo the styling the file is able to build without running out of memory.
The output xlsx file will have 8 sheets, each with up to 35,000 rows each.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
