poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nawanit, Niraj" <nawa...@amazon.com>
Subject Re: problem with possible memory leakage in my code
Date Wed, 06 Mar 2013 11:30:54 GMT
Did some more research. It does not seem to be memory leakage as when I execute cell.getStringCellValue()
for same cells again and again, memory used remains almost same after first call for given
cell. Must be some caching of cell data inside workbook object.

Thanks
Niraj

From: <Nawanit>, "Nawanit, Niraj" <nawanit@amazon.com<mailto:nawanit@amazon.com>>
Date: Wednesday, March 6, 2013 4:24 AM
To: "dev@poi.apache.org<mailto:dev@poi.apache.org>" <dev@poi.apache.org<mailto:dev@poi.apache.org>>
Subject: problem with possible memory leakage in my code

Hi all,

I have written a below small code:


XSSFWorkbook workbook = new XSSFWorkbook("/Users/nawanit/Desktop/test.xlsx");

XSSFSheet sh = workbook.getSheet("Sheet1");

for (int i=0; i < sh.getLastRowNum(); i++) {

XSSFRow row = sh.getRow(i);

if (row == null) continue;

for (int j=0; j < row.getLastCellNum(); j++) {

XSSFCell cell = row.getCell(j);

if (cell != null) {

String s = cell.getStringCellValue();

}

}

}


The XLSX file is of say 2000 rows and 150 columns and contains string type cells only. I am
observing that 'String s = cell.getStringCellValue();' is causing heap memory to increase
for each call even when I store its return value in a local scope variable. In total, workbook
took around 381 MB of heap and the FOR loops caused extra 90 MB of heap to be used.


Is this a known issue? I am using Apache POI 3.7 in my project. Should it be treated as a
possible memory leak problem?


Thanks

Niraj


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message