|
|
|
|
program slows down after upgrade to 1.5.0?
Posted:
Mar 7, 2006 11:15 PM
|
|
|
I recently upgraded to JDK 1.5.0 and this program I was working on suddenly slows down tremedously to the point where it just hangs. The strange thing is that it only happens at times; sometimes, when I run the program, it works perfectly fine, then the next time I run it, it just hangs when it loads and I can't even do anything with it. This never happens when I was using JDK 1.4.2
The program can be a bit of a resource hog; it parses XML documents and draws it as a graph, so it does slow down at times when I load a huge document (but never to the point where it just hangs). After the upgrade to 1.5.0, it even hangs when a small document is loaded. Swing is used for the interface.
Any idea/suggestion on why the program hangs occasionally after the upgrade to 1.5.0?
|
|
|
|
|
|
|
|
|
Re: program slows down after upgrade to 1.5.0?
Posted:
Mar 8, 2006 1:01 PM
in response to: ryoko
|
|
|
Do you use buffered images to display the graph?
As of 1.5 all buffered images are now managed. (http://java.sun.com/j2se/1.5.0/docs/guide/2d/new_features.html) I’ve run into slowdowns with code that generates buffered images rapidly. My images were being regenerated for no reason, so my fix was simple, YMMV.
|
|
|
|
|
|
|
|
Re: program slows down after upgrade to 1.5.0?
Posted:
Mar 17, 2006 1:30 PM
in response to: ryoko
|
|
|
Well, I've checked it out using jconsole. Turns out it was a deadlock caused between a synchronized method and JComponent.reshape(), which is called by JScrollBar.setValue().
I did not personally write the class that has the synchronized method (it's a class that extends Panel), so I didn't want to touch that method if possible. Currently I just had the JScrollBar.setValue() commented out to bypass the problem.
Since JComponent.reshape() is deprecated in JDK 5, and I never had deadlock problems when running in 1.4.2, I'm assuming there's something up with calling the deprecated method. But since it's called by JScrollBar.setValue(), I don't know what I can do about it aside from not calling setValue() at all. Any suggestions? The program does seem to function fine with it commented out so it's not a major problem, but I would rather solve the problem instead of just bypassing it.
Thanks a lot for all the help!
|
|
|
|
|
|
|
|
Re: program slows down after upgrade to 1.5.0?
Posted:
Mar 17, 2006 1:37 PM
in response to: ryoko
|
|
|
Is the call to setValue() happening on the event processing thread? Swing isn't threadsafe, and calling setValue() (and other Swing methods) from threads other than the event processing thread is a good way to get deadlock.
Check out http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html for a complete example.
|
|
|
|
|