I am trying to create a JTable that shows 41000 rows of data, I had the same code working fine for another JTable that I needed to create with only 4457 rows so my problem does not come from the data. My program execution takes 25 minutes to compute all the values that need to be shown in my user interface. Once the program execution finishes, I receive the following error message:
"Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Vector.<init>(Unknown Source)
at java.util.Vector.<init>(Unknown Source)
at javax.swing.table.DefaultTableModel.convertToVector(Unknown Source)
at javax.swing.table.DefaultTableModel.convertToVector(Unknown Source)
at javax.swing.table.DefaultTableModel.setDataVector(Unknown Source)
at javax.swing.table.DefaultTableModel.<init>(Unknown Source)"
Is it impossible to create a JTable with 41000 rows? Is that too large for the JTable to be created? I don't think that something is wrong with my program since I had the same code working fine for another table made of 4457 rows.
4457 != 41000. It's obviuos that it depends in your object side.
Is it impossible to create a JTable with 41000 rows?
It all depends in the Object that you are rendering. It's differnt an object with only 1 field that an object that more. It depends in your JVM configuration as the comments said, adding more memory can be a solution -Xmx2048m
Is that too many rows for the JTable to be created?
The same answer. It depends of the type of Objects you are using. If the object is too large it can better to use Pagination or make a better approach for this.