This discussion is archived
6 Replies Latest reply: Jan 29, 2012 9:26 PM by 907809 RSS

Java Applet is much slower than Java Application?

907809 Newbie
Currently Being Moderated
Hello,

We are developing Java applet which will be running on various browsers, such as IE, FireFox, Chrome and etc. Our applet is to get the data from data source and generate document using Graphics2D. The issue currently we have is performance of the applet. We use NetBeans for IDE and if we make the applet run from NetBeans(as standalone Java application), it takes less than 30 seconds to complete document generation. However if we make it run on browser, it takes more than 53 seconds. Any body knows why the applet is much slower than standalone application?

This is what we've tried so far. When we made it run using JNLP, it took more than 53 seconds which is same with applet. So, we've put JVM option, "-Xms512m -Xmx1024m" and we got a better performance which is less than 30 seconds. BUT, even with this option in JVM and putting "-Xms512m -Xmx1024m" to java_arguments property in Applet tag in web page, the performance of applet running on browser doesn't change at all and it took more than 53 seconds.

It would be appreciated if you help us to improve the performance of the applet. If this is not acheivable, we'd like to understand what Java Applet is much slower than Java Application.

Thanks in advance.
  • 1. Re: Java Applet is much slower than Java Application?
    EJP Guru
    Currently Being Moderated
    if we make the applet run from NetBeans(as standalone Java application), it takes less than 30 seconds to complete document generation.
    So maybe Netbeans already has a JVM primed and ready to run.
    However if we make it run on browser, it takes more than 53 seconds. Any body knows why the applet is much slower than standalone application?
    Does it matter? Do you have any users who are in a position to make the comparison?
  • 2. Re: Java Applet is much slower than Java Application?
    gimbal2 Guru
    Currently Being Moderated
    So, we've put JVM option, "-Xms512m -Xmx1024m" and we got a better performance which is less than 30 seconds.
    That puzzles me. The amount of free heap space shouldn't impact performance at all. Yet it does according to you. The only thing I can think of is really poor garbage collection performance, with more heap space it would have more breathing space.
    even with this option in JVM and putting "-Xms512m -Xmx1024m" to java_arguments property in Applet tag in web page, the performance of applet running on browser doesn't change at all and it took more than 53 seconds.
    How old is the installed Java plugin I wonder? You can only change the heap size through the applet tag when running the "new" Java plugin (Java 6 update 10 and up).


    Another thing you can try is in Netbeans to make the heap space small on purpose, like max=128m. Does that make the application slower when running under Netbeans? And while were on that topic, is Netbeans using the exact same JDK/JRE as the browser plugin?
  • 3. Re: Java Applet is much slower than Java Application?
    907809 Newbie
    Currently Being Moderated
    For our testing, we've beeing using JRE 1.6.0.26.

    If we set heap size to max=128m in Netbeans, we can see that the application is getting slower and slower and finally almost hanged when it generate the document. but with max=256m, it works ok even though it is slower.

    we've been using same JDK/JRE for both Netbeans and browser plugin at same PC.
  • 4. Re: Java Applet is much slower than Java Application?
    907809 Newbie
    Currently Being Moderated
    actually, we have active X version of the this application, and the performance is much better than Java applet version. we understand that Java application/applet could be slower than native application, but we'd like to achieve reasonable performance for Java applet version too.

    again, it would be appreciated if proper solution/tip is provided....
  • 5. Re: Java Applet is much slower than Java Application?
    817264 Journeyer
    Currently Being Moderated
    0. I assume you are using "new generation plugin" with 6u26 (not old plugin that works inside the browser process)

    1. Use jVisualVM or jconsole to observe heap consumption by standalone app, webstart app or applet
    Do you observe same memory consumption patern? same heap settings?
    (For applet make sure to attach to out of browser process)

    2. Enable full tracing as described here http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html#gcexdf
    and post trace here. At least details on what is result JNLP file in case of applet and what are JVM parameters.
    (I assume you use JNLP applet and duplicate parameters in the JNLP file and html page tag)

    3. You may attach profile to applet/webstart and get some data on what is slower comparing to standalone launch.
    See http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html#gcexdo
    Given that it never fails with OOM it seem you might have some caches based on weak/soft references that
    grow too big. Or may be your app is filling internal deployment memory caches.
    Heap dump or heap analysis may give you hints what occupies most of the heap. Then you can think how to reduce heap consumption.
  • 6. Re: Java Applet is much slower than Java Application?
    907809 Newbie
    Currently Being Moderated
    Thanks for your help and sorry for late response. I've been in holidays...

    I've posted the files you've asked here, https://skydrive-df.live.com/?cid=C7E677B8EC24DCC1&id=C7E677B8EC24DCC1%21376

    For memory consumption, please find attachment, memory consumption comparison.zip. Look JNLP version uses more memory than Plugin version

    For tracing result, please find the attachements, trace.zip one with JNLP and the other with Plugin.

    Thanks for your help in advance.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points