• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

JTable fireTableDataChanged() performance problem

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you understand me correctly.
For the row deletion, you can always have a custom synchronized method.
 
The moustache of a titan! The ad of a flea:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic