You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Ajit Gupta <Aj...@avotus.com> on 2005/06/28 22:00:10 UTC
Out Of Memory Problem with large file (60k rows with 6 columns)
Hi !
I receive a java.lang.OutOfMemoryError, while I was creating excel file
which contains (60k rows with 6 columns)).
Has anyone knows a solution to this problem that does not involve
adding more Memory (I have 2Gig on my workstation) or increasing
Heap size.
I have tried to debug HSSFWorkbook source code and
Find out that error arise at getBytes () method at byte [] retval = new
byte [totalsize] line of the HSSFWorkbook class
*******************************Code*********************
public byte[] getBytes()
{
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "HSSFWorkbook.getBytes()");
// before getting the workbook size we must tell the sheets that
// serialization is about to occur.
for (int k = 0; k < sheets.size(); k++)
((HSSFSheet) sheets.get(k)).getSheet().preSerialize();
int wbsize = workbook.getSize();
// log.debug("REMOVEME: old sizing method
"+workbook.serialize().length);
// ArrayList sheetbytes = new ArrayList(sheets.size());
int totalsize = wbsize;
for (int k = 0; k < sheets.size(); k++)
{
workbook.setSheetBof(k, totalsize);
totalsize += ((HSSFSheet)
sheets.get(k)).getSheet().getSize();
}
byte[] retval = new byte[totalsize];*****************error arise
int pos = workbook.serialize(0, retval);
for (int k = 0; k < sheets.size(); k++)
{
// byte[] sb = (byte[])sheetbytes.get(k);
// System.arraycopy(sb, 0, retval, pos, sb.length);
pos += ((HSSFSheet) sheets.get(k)).getSheet().serialize(pos,
retval); // sb.length;
}
/* for (int k = pos; k < totalsize; k++)
{
retval[k] = 0;
}*/
return retval;
}
**************code end********************
Solution will be really appreciated.
regards,
Ajit