Skip to main content

program slows down after upgrade to 1.5.0?

5 replies [Last post]
Joined: 2006-03-08

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?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-03-08

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!

Joined: 2005-05-23

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
for a complete example.

Joined: 2006-02-02

Do you use buffered images to display the graph?

As of 1.5 all buffered images are now managed. (
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.

Joined: 2003-06-10

Have you tried attaching jconsole to the application?

Start your app with "" added to the command line.

Then start jconsole. A connection dialog box should list your application.

For more information, take a look at:
[b]Using JConsole to Monitor Applications[/b]

Hope this helps - please post a followup message when you learn more about what is happening.

For even more troubleshooting help, check these documents:

[b]Troubleshooting Guide for J2SE 5.0[/b]

[b]HPROF: A Heap/CPU Profiling Tool in J2SE 5.0[/b]

Joined: 2004-01-30

Check out It might shed some light on your problem.