Why does this get "Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space" error?

Why do I get a Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space because of objects[i]=rs.getObject(i+1);? There are about 10,000 records with about 4,000 characters per record.

String[] tableColumnsName = {idString, dateEnteredString, entryString, operatorString, licenseNoString, lastModifiedString}; DefaultTableModel aModel = (DefaultTableModel) logEntryTable.getModel(); aModel.setColumnIdentifiers(tableColumnsName); ResultSetMetaData rsmd; try { rsmd = rs.getMetaData(); int colNo = rsmd.getColumnCount(); while(rs.next()){ Object[] objects = new Object[colNo]; for(int i=0;i<colNo;i++){ objects[i]=rs.getObject(i+1); } aModel.addRow(objects); } logEntryTable.setModel(aModel); logEntryTable.getColumnModel().getColumn(0).setMaxWidth(30); rs.close(); } catch (SQLException e) { e.printStackTrace(); showCantConnectErrorDialog(); }

-------------Problems Reply------------

Your JVM has run out of memory. Potentially when JVM is short on memory OutOfMemoryError may appear in any place in the code that allocates memory. Try increasing your heap size using -Xmx parameter.

I agree with ^^ you need to increase your heap size, or if that's not possible, reduce everything to get it as space efficient as possible.

Category:java Views:1 Time:2011-05-08
Tags: java memory heap

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.086 (s). 11 q(s)