Free Support Forum - aspose.com

Memory error

Hi,

Workbook workbook = new Workbook();
Worksheets worksheets = workbook.getWorksheets();

for(int i = worksheets.size() - 1; i > 0; --i) {
worksheets.removeSheet(i);
}

Worksheet sheet = worksheets.getSheet(0);
sheet.setName("Sheet1");
Cells cells = sheet.getCells();

for(int i=0; i<treeDAR.getRowCount(); i++) {
for(int c=0; c < treeDAR.getColumnCount(); c++) {
cells.getCell(i, c).setValue(String.valueOf(treeDAR.getValueAt(i, c)));
}
}

JOptionPane.showMessageDialog(this,"1/4 Done");

System.gc();

JOptionPane.showMessageDialog(this,"1/2 Done");

workbook.save("D:/AlphabeticalList.xls");

JOptionPane.showMessageDialog(this,"Done");

////////////////////////////

i am using the above code for exporting to excel.

upto 3000 rows x 120 cols its working fine, but when i try to export 4000 rows X 120 cols its giving "out of memory" error.

- regards,

Venkatasamy


This message was posted using Aspose.Live 2 Forum

Hi,

Maybe the default memory for JVM is not enough to deal with your data, you can try using -Xmx option for java.exe to specify more memory than default for JVM when run your program.

Hi,

I have tried but its not working. I am able to create upto 6000 rows x 120 cols in csv format but i am unable to do it using aspose. plz advice.

- regards,

Venkatasamy.

Hi,

I tried following code much alike yours with -Xmx512m option to create 6000x200 cells, it created the result file whose size is 41M. Would you please specify more memory and try again?

for(int i=0; i<6000; i++) {
for(int c=0; c < 200; c++) {
cells.getCell(i, c).setValue("value for " + i + "," + c);
}
}

Hi,

I tried your code with -Xmx512m , its giving the same error.

System configuration - Inter(R) core(TM) Duo @1.66 Ghz, 1 GB RAM.

Is this Error because of the evaluation version. ?

- regards,

Venkatasamy.

Hi,

Did you build more Swing or AWT Components in your program? Maybe that is the cause for more memory. I think you can try more memory for option –Xmx. And following is my complete test code, as you see, it builds no more component than JOptionPane, maybe your case is more complex and needs more memory.

public static void main(String[] args) throws Exception
{
Workbook workbook = new Workbook();
Worksheets worksheets = workbook.getWorksheets();

for(int i = worksheets.size() - 1; i > 0; --i) {
worksheets.removeSheet(i);
}

Worksheet sheet = worksheets.getSheet(0);
sheet.setName("Sheet1");
Cells cells = sheet.getCells();
for(int i=0; i<6000; i++) {
for(int c=0; c < 200; c++) {
cells.getCell(i, c).setValue("value for " + i + "," + c);
}
}

JOptionPane.showMessageDialog(null,"1/4 Done");

System.gc();

JOptionPane.showMessageDialog(null,"1/2 Done");

workbook.save("AlphabeticalList.xls");

JOptionPane.showMessageDialog(null,"Done");
}

Hi,

Thanks for your support.

Plz let me know if you find a solution to handle large reports.

- regards,

Venkatasamy.