Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to fix 1

Status
Not open for further replies.

Miros

Programmer
Jan 27, 2001
506
US
My program is working nicely, thank you everyone.

However, being a total maniac, I'm trying to jam several thousand rows into a JTable. Naturally, after about 1100, it runs out of memory.

I think it's happening when the JTable tries to do the insert, not when I add the row class to my ArrayList (although it could happen then as well).

Is there anything I can do to make more memory available?
 
How much data do your rows contain?

And yes, you can start the jvm with special parameters.
Code:
java -X
shows special parameters.
Code:
java -Xms128M -Xmx256M YourMainClass
will start the jvm with 128MB RAM initially, and a maximum of 256MB i.e.



seeking a job as java-programmer in Berlin:
 
Here's the data from my row class.

private int itemNumber ;
private String itemName ;
private String itemCreator ;
private int itemRevision ;
private int itemSetNumber ;
private String itemSetItems ;
private String itemRecommendedItems ;
private String itemRequiredItems ;
private Boolean itemRecolors ;
private Boolean itemDownloaded ;
private Boolean itemFree ;

itemSetItems, itemRecommendedItems, and itemRequiredItems are quite often "0", but could possibly be quite long (up to 256 characters).

Null or "" caused my input routine to crash, so I changed the default value to "0".

I don't think it's an excessive amount per record, it's just the number of records that's excessive...
 
Thanks!

I was able to read almost 5000 records, much better than 1100!

Gonna up the max a little more and I should be able to read my whole file, with room for expansion.
 
You're better putting next/previous type controls with the table and having 'pages' of results in it. No user is going to thank you for gobbling up that much of their memory.

Tim
 
I'm probably the only person who will ever use this program.

I was thinking about doing my own sort, so then I could do next/previous controls.

Do you just send a "cell contents changed" for every visible cell when the next/previous button gets hit?

I also thought that the JTable itself only used memory for the visible cells, basically using the scroll bar as a next/previous control... Am I mistaken?

I really don't have an easy way to leave the data on disk and just load what I need, so my ArrayList of my objects still needs to sit in memory.
 
JTable uses a TableModel to contain the actual data (namely a DefaultTableModel unless you provide your own implementation). The JTable itself is a 'view' on the data in this model. The DefaultTableModel will hold ALL the data regardless of which portion is currently displayed.

You could modify this behaviour by writing your own; either implement TableModel, subclass AbstractTableModel or DefaultTableModel, depending on your needs.

The Swing controls which process collections of data all use a view/model paradigm like this, and it's my experience that the default models in each case are coded to hold all the data all the time.

Tim
 
Too much trouble, especially if I'm the only person who's going to use it!
 
Too much trouble, especially if I'm the only person who's going to use it.

Yes, I got that. I'm just responding to your thought that JTable only stored visible cells.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top