Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Swing Performance

Posted on 2004-09-01
10
Medium Priority
?
215 Views
Last Modified: 2013-12-29
I've been developing my swing application on my laptop (P4 HT 3.06 ghz  512MB) and it runs essentially seamlessly.  I have been developing it on this machine for some time now and had never given consideration to performance implications for running on a slower system.  The desktops at our company are P4 1.8ghz 256MB machines and the application runs absolutely horrendously...I mean to the point that the productivity loss to the person using it would make it not worthwhile to use.

Does anybody have any advice or maybe links to resources that I can check out so that I can attempt to streamline the code and perhaps make it more efficient?

Thanks,
David
0
Comment
Question by:lomidien
10 Comments
 
LVL 3

Expert Comment

by:CI-Ia0s
ID: 11957971
My first suggestion: cut any nonessential stuff, right from the start. If left in debugs, etc. take them out.
Second: Try running Runtime.gc() occasionally to reclaim some memory. I know it should be running automatically, but just to be sure...
Third: The issue with Java/Swing is RAM. Usually the processor is not an issue (heck, I'm on a 667 :P ). Try to do things in smaller chunks and not have as many things happening at once. For instance, if you transfer files, transfer them 5 MB at a time, etc. This allows Java to free up memory between tasks.

I hope this helps a bit...
0
 
LVL 15

Accepted Solution

by:
Javatm earned 2000 total points
ID: 11957989
Does anybody have any advice or maybe links to resources that I can check out so that I can attempt to streamline the code and perhaps make it more efficient?

1. 1st thing that you need to remember is to close all open streams.
2. You can finalize any objects that you want to be suggested in GC.
3. Still not resolve ? use a java profiler to monitor the efficiency of
    your java program. A profiler detects any problem in your codes.

Here is a link that will help you in the performance of your application :
http://www.javaperformancetuning.com/resources.shtml

If you want a java profiler here are the best :

Java Profiler - JProfiler :
http://www.ej-technologies.com/ products/jprofiler/overview.html

Extensible Java Profiler :
http://ejp.sourceforge.net

Notes : JProfiler is free to use for a month I think then you need to purchase
it unless you request for another trail.

Hope that helps . . .
Javatm

0
 
LVL 15

Expert Comment

by:Javatm
ID: 11958006
If you want to finalze objects in java here are the examples :
http://www.janeg.ca/scjp/gc/finalize.html
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 92

Expert Comment

by:objects
ID: 11958477
It should run fine, where exactly are you getting poor performance.
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11959147
> The desktops at our company are P4 1.8ghz 256MB machines and the application runs absolutely horrendously...
> I mean to the point that the productivity loss to the person using it would make it not worthwhile to use

Also check the JVM or JDK versions and codes varies depending on the version.
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 11959654
You could try changing from SWING to swt(standard widget toolkit).  The SWT library is the tool set used for creating the Eclipse IDE.  See the following links:
http://www.eclipse.org/swt/
http://www.eclipse.org/articles/Article-SWT-Design-1/SWT-Design-1.html
0
 

Author Comment

by:lomidien
ID: 11959655
I ran the Profilers on the application and the hangup seems to be the following:

I have a CardLayout area of the main frame which holds several sub-panels.  These sub-panels are displayed depending on which JTree item is selected at that time.  In my code, I have all of the panels being initialized on startup (10 panels with multiple swing components on each).  What I would like to do is this:  Upon displaying the login screen, which happens before the panels are instantiated, I would like to run the panels instantiations in a separate thread so that it can happen concurrently with the user typing in their password.

I've tried launching it in it's own thread, but it doesn't seem to process concurrently at all...rather the thread waits for some reason.

Any ideas?
0
 
LVL 92

Expert Comment

by:objects
ID: 11959685
What is making the creation of the panels time consuming?
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11959981
> I would like to run the panels instantiations in a separate thread so that it can happen concurrently.

I would you do that ? making a seperate thread can add memory consumption and program gets too complicated
if not wisely done. Well depending on how you implemented it. Have you tried removing the thread yet ?
0
 
LVL 7

Expert Comment

by:grim_toaster
ID: 11961118
There are many things to consider, including what else is running on these desktop machines that isn't running on your laptop (for example any virus checker software), or any other heavy applications (servers, etc).  Also (as mentioned previously), the JVM differences between the machines, especially the -Xms and -Xmx settings, and the JDK version.

As for wanting to load other parts of the application using a seperate thread, this is standard Swing design (perhaps unfortunately), and there are standard utility classes available to do these sorts of things (SwingUtilities if I remember correctly).  But perhaps we could provide more beneficial responses given the code that is causing the problems.

One other question though, would be how is the application loaded?  As in, is the entire application Swing based, or do you call some form of midtier?  If so, could this be where it is waiting?  And what is it trying to do?

Finally, you say that you've run the profilers, what profilers?  Memory, thread lock-detection or execution profiling?  Or all of the above?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question