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[] tableColu开发者_运维知识库mnsName = {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();
}
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.
精彩评论