1

We have a monitoring application built on swt and running on linux. we have few buttons and a dynamic part that changes as we click on these buttons. The problem is that if some ones click too rapidly the cpu could reach 100% and hanging forever. We observed this rapid cpu spikes only on Ubuntu Linux where as windows it runs without on itch. We are sure that our app does repainting whenever we click (we have dynamic part) the button and that's by design. The problem is not alone with the dynamic part. One solution is to ignore rapid clicks.

We are wondering if we can ignore rapid Button clicks to avoid cpu spiking all the way to 100%. If that doesn't work we may have to redesign the dynamic part which we prefer as last option. suggestions/comments are greatly appreciated.

jitter
  • 53,475
  • 11
  • 111
  • 124
Kishore
  • 403
  • 4
  • 11

5 Answers5

0

It sounds like the application is simply deadlocking. Are you using threads?

Check to see if the repaint is indeed the root cause of the application hanging. Also check to determine which thread it is in using:

Thread.currentThread()

If it is the main thread, then something is inherently wrong; it could be a problem in Java itself. If it is a thread, make sure that it isn't waiting for another thread to finish synchronizing.

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
  • Thanks. I used Jconsole to monitor the app and to detect deadlocks and i see none of them in deadlock. – Kishore Mar 15 '10 at 18:06
0

I have the same problem in Ubuntu. But on OpenSuse, it seems a lot better.

Things you can try:

Set the anti alias and advanced option of the GC, like:

gc.setAntialias(SWT.OFF);
gc.setTextAntialias(SWT.OFF);
gc.setAdvanced(false);

And check if you are using the commercial graphic driver (i.e. from NVIDIA or ATI) and not the open source driver.

nanda
  • 24,458
  • 13
  • 71
  • 90
0

Another solution is to increase your memory with -Xms512m -Xmx512m

nanda
  • 24,458
  • 13
  • 71
  • 90
  • With more investigation i found that my linux box is running out of memory and i see nothing in the logs. My heap memory is within limits. So now im suspecting there could be some native memory leak since we are using swt. When i looked at the code one class is using finalize method to dispose swt object. I'm suspecting this could be the culprit. Is this object getting finalized by gc but leaving the native memory resources and causing leaks? – Kishore Mar 16 '10 at 16:13
  • could be... finalize is undeterministic. You must not use finalize for freeing the memory in SWT. – nanda Mar 22 '10 at 14:28
  • Yes. We have code to free native memory in finalize methods. Though we haven't re-factored it but we have plan to do that. – Kishore Jun 23 '10 at 14:52
0

Try this or use pstack or lsstack. When the app runs a long time (or hangs) is when it's begging you to just take a look and see what it's doing.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
0

Many people have experienced performance problems (i.e. very high CPU consumption) with SWT applications on Gtk+ when updating widgets too often. The actual cause seems to be Gtk+.

Although a bit outdated, here's a throughout explanation of such performance problems.

You could try replacing your SWT components with embedded Swing ones and check whether the problems is still reproducible.

noe
  • 1,684
  • 1
  • 17
  • 35