Solved

Swing Performance

Posted on 2004-09-01
10
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

734 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