views:

236

answers:

4

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.

A: 

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
Thanks. I used Jconsole to monitor the app and to detect deadlocks and i see none of them in deadlock.
Kishore
A: 

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
A: 

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

nanda
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
could be... finalize is undeterministic. You must not use finalize for freeing the memory in SWT.
nanda
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
A: 

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.

Mike Dunlavey