This is resolved now :). It has nothing to do with SXSSFWorkbook. One particular column in the report (Represents error in report) needs to be RED in color. So I applied Style to that column. Instead of creating the Style outside the FOR loop and applying it for all cells that comes under the column, i was creating a style each time i write error. Out of 1 million records, if 1/2 a million are having errors my code was generating 1/2 a million CellStyles. That was eating my heap memory.
Following link helped me to resolve it. http://poi.apache.org/faq.html#faq-N100EF On Wed, Jun 4, 2014 at 3:32 PM, Renjith R <[email protected]> wrote: > I am using SXSSF to write 1 Million(worst case scenario) records. > > Following is the way i have coded it. > I have to write the records to an already existing excel template. This > template is > available in the class path. I will copy this template to a common > location. Load this file using XSSFWorkBook. > SXSSFWorkbook is initialized with XSSFWorkBook and window size(-1) as > parameter. > > when ever the record count reaches multiple of 100, i will flush the > sheet. > > Pseudo Code: > if(count % 100 == 0){ > ((SXSSFSheet)sheet).flush(100); //keeps only 100 rows in memory > } > > But while executing this, heap memory is gradually increasing and it ends > up in Outofmemory exception. Maximum heap memory size of my machine is > about 1.5 GB. > > Is it an expected behaviour? ie. is it expected to go beyond 1.5 GB while > writing record of size ~ 1 Million? > > -- > *RENJITH R* > 9446011990 > -- *RENJITH R* 9446011990
