How did you check your computer memory? With task manager? Try Runtime.getRuntime().freeMemory() and Runtime.getRuntime().totalMemory() every 500 lines or so. If freememory gets close to 0, then you should raise the maxMemory for the virtual machine. This can be done by adding -DXmx512m to the start parameters of your app.
Greets, Alex ________________________________ Von: Jordi Moltó [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 11. März 2008 11:43 An: [EMAIL PROTECTED] Betreff: Out of memory with POI-HSSF, when writing Excel file I got a java.lang.OutOfMemoryError exception when I am writing to an Excel file. I use poi 2.5.1. This happens after writing 7,800 lines. Checking to the computer memory, it seems however that I still have plenty of memory. Also, writing smaller files works fine. Here is the code (which I think is no surprise): HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(sheetTitle); HSSFRow row; HSSFCell cell; for (int rownum = 0; rownum <= jdbTable.getRowCount(); rownum++) { row = sheet.createRow((short)(rownum+2)); for (int cellnum = 0; cellnum < jdbTable.getColumnCount();cellnum++) { cell = row.createCell((short)cellnum); Object value = jdbTable.getValueAt(rownum - 1, cellnum); if (jdbTable.getColumnClass(cellnum).getName().equals("java.lang.Integer")) cell.setCellValue(((Integer)value).intValue()); else if (jdbTable.getColumnClass(cellnum).getName().equals("java.lang.Double")) cell.setCellValue(((Double)value).doubleValue()); else if (jdbTable.getColumnClass(cellnum).getName().equals("java.lang.String")) cell.setCellValue((String)value); } } wb.write(fos); fos.close(); Thank you for any advice. -- Jordi Moltó ABM Informática, S.L. [EMAIL PROTECTED] ________________________________ Este mensaje y sus anexos pueden contener información confidencial y/o con derecho legal. Está dirigido únicamente a la persona/s o entidad/es reseñadas como único destinatario autorizado. Si este mensaje le hubiera llegado por error, por favor elimínelo sin revisarlo ni reenviarlo y notifíquelo inmediatamente al remitente. Gracias por su colaboración. ________________________________ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
