You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Christian Kellner <Ke...@technotrans.de> on 2005/11/10 09:51:00 UTC
Memory Problem
Hi List.
I am using the newest version of the poi-lib to read values from an excel sheet. So now, everytime when i call the method to read data from the excel sheet, it incrases the memory usage of my application (sometimes + 1 MB, otherwise + 500 kb).
If i let it run the whole night, i sure will have a "Memory Out Of Bounds Exception".
I looked with a profile on my code and it seems to be a problem with the poi-lib.
This is my code to read data.
As you can see, I added this:
wb.removeSheetAt(0);
wb = null;
sheet = null;
cell = null;
System.runFinalization();
and hoped that it was a problem by not removing any objects, but it seams to be anothe one??
Thank you all..
HSSFWorkbook wb; //For representing an excel file
HSSFSheet sheet; //An excel file may have many sheets(tabs)inside
HSSFCell cell; // A constituent of a row
InputStream is;
private void loadLanguages(){
if(list.size()!=0)
list.removeAllElements();
try {
is = new FileInputStream(f.getAbsolutePath()+ "\\languages\\" + McConfig.actLanguage +".xls");
wb = new HSSFWorkbook(new POIFSFileSystem(is));
sheet = wb.getSheetAt(0); //First sheet of the excel file
for(int i=0;i<sheet.getLastRowNum()+1;i++){
list.add(sheet.getRow(i).getCell((short)0).getStringCellValue());
}
McIoTranslator.list = McIoLoadLanguage.getTranslatedList();
McIoTranslator.fill();
isGeladen = true;
wb.removeSheetAt(0);
wb = null;
sheet = null;
cell = null;
System.runFinalization();
is.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
Re: Memory Problem
Posted by ac...@apache.org.
can you do a run with -Xaprof passed to the VM and post hte output? I
may be blind but I dont' see anything except maybe your singleton
McIoTranslator keeps stuff around..
Christian Kellner wrote:
> Hi List.
>
> I am using the newest version of the poi-lib to read values from an excel sheet. So now, everytime when i call the method to read data from the excel sheet, it incrases the memory usage of my application (sometimes + 1 MB, otherwise + 500 kb).
> If i let it run the whole night, i sure will have a "Memory Out Of Bounds Exception".
>
> I looked with a profile on my code and it seems to be a problem with the poi-lib.
>
> This is my code to read data.
>
> As you can see, I added this:
>
> wb.removeSheetAt(0);
> wb = null;
> sheet = null;
> cell = null;
> System.runFinalization();
>
> and hoped that it was a problem by not removing any objects, but it seams to be anothe one??
>
> Thank you all..
>
> HSSFWorkbook wb; //For representing an excel file
> HSSFSheet sheet; //An excel file may have many sheets(tabs)inside
> HSSFCell cell; // A constituent of a row
> InputStream is;
>
> private void loadLanguages(){
> if(list.size()!=0)
> list.removeAllElements();
>
> try {
> is = new FileInputStream(f.getAbsolutePath()+ "\\languages\\" + McConfig.actLanguage +".xls");
> wb = new HSSFWorkbook(new POIFSFileSystem(is));
> sheet = wb.getSheetAt(0); //First sheet of the excel file
>
> for(int i=0;i<sheet.getLastRowNum()+1;i++){
> list.add(sheet.getRow(i).getCell((short)0).getStringCellValue());
> }
> McIoTranslator.list = McIoLoadLanguage.getTranslatedList();
> McIoTranslator.fill();
> isGeladen = true;
> wb.removeSheetAt(0);
> wb = null;
> sheet = null;
> cell = null;
> System.runFinalization();
> is.close();
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
>
>
--
Andrew C. Oliver
SuperLink Software, Inc.
Java to Excel using POI
http://www.superlinksoftware.com/services/poi
Commercial support including features added/implemented, bugs fixed.
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/