• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable fireTableDataChanged() performance problem  RSS feed

 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I have build an application and I used swing. Technically the app is working fine, but the memory used is increasing with time. This happens when the user is viewing a JPanel containing a JTable.
If the user doesn't see the JTable( the table is not visible) the app doesn't need more than 40-45 MB RAM after 2 hours of running.

The application executes some code on 10 threads. The JTable has 10 rows ( one row for every thread) and every row has a JProgressBar which shows the percentage of the code that has been completed(I split the running code in more steps). To update the JProgressBar value I need to update the JTable so I use the following code:



and it's working great but the memory used the program is increasing even if I run garbage collector. I know this is the code that is causing the problem because when I remove it the memory is not increasing, so what I am looking is a solution to my problem.

Should I use some synchronized solution to update the table, so I can avoid simultaneous updates?

Thank you for your help and sorry for my bad english.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the existing details you have provided, how are you updating the actual values ?
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:With the existing details you have provided, how are you updating the actual values ?



Hi. Thanks for posting. Well Like I said in the first post, on every thread when a certain part of the code is finish I use something like this



 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I would not do it that way.
The JProgressBar is the renderer. It should be picking up the value from the underlying model.
When you want to change the value, you should be modifying the value of the table model. If you use the methods provided in the table model, it will internally fire the appropriate fireXXX methods to ensure that your table reflects those updated values.

 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Well I would not do it that way.
The JProgressBar is the renderer. It should be picking up the value from the underlying model.
When you want to change the value, you should be modifying the value of the table model. If you use the methods provided in the table model, it will internally fire the appropriate fireXXX methods to ensure that your table reflects those updated values.




So basically what you say is that I should use something like this to change the progressBar value
??

if yes I must say that the rows in the table are being deleted after the progress is at 100% so updating the table on a certain row and column might cause some problems in case another row is deleted in the same time.

Let me know if I understand what you said in the previous post, so I can try your method.

Thank you
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you understand me correctly.
For the row deletion, you can always have a custom synchronized method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!