Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4173737

Java Plugin uses drastic amounts of memory while IE's native VM does not

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P1 P1
    • None
    • 1.1.1
    • deploy
    • x86
    • windows_nt

      Enclosed is a spreadsheet (Excel 5.0) showing the memory problems when we
      run the Classic Blend applet in Java Plugin 1.1 (JRE 1.1.6). When we run
      the same applet in Internet Explorer's native Java VM, there are no memory
      problems. The problem is very repeatable (ie happens every time) when
      running the whole applet.

      As I mentioned on the phone, we have written two large applications in
      SmallTalk using Visual Works from ObjectShare. The Visual Works server
      runs on a Sun Enterprise 3000 in our beta/preprod environment and an
      Enterprise 4000 in production. In the Visual Works server image is the
      Classic Blend product from Applied Reasoning. Classic Blend "scrapes" the
      screen drawing commands off the Visual Works server and pipes them to their
      Java applet that runs in Java Plugin 1.1's JRE. The Classic Blend product
      uses a table drawing widget called JKIT from Instantiations Corp. which
      uses AWT to draw tables. The table drawing appears to be the worst
      offender in terms of eating up memory. In the spreadsheet you will find a
      couple of rows where total memory allocated goes up by 5+ MBs with Java
      Plugin and 0 MBs with IE's native VM. Those rows are where JKIT is drawing
      tables.

      I have created a testcase using the JKit example classes. Unfortunately,
      I was not able to create a testcase without using the JKit classes, so
      they are included. Fortunately, I was able to determine a starting point
      that seems to be causing the problem. Hopefully the sun engineers can
      checkpoint this message to watch the execution and determine the memory
      usage.

      The testcase is a simple Java applet that contains buttons that launch
      various JKit examples.

      The class and java files are included in the test.jar file. The html
      files are included in html.zip.

      I ran this test on Win NT4.0 SP3, 128MB memory. I used the FNord web
      server to serve up the html and jar files.

      Here is the case:

      Start the NT Task Manager. Select the Performance tab. What we are
      concerned with is the MEM Usage value. This indicates the total memory
      used by the system. You will NOT see the memory usage by watching the
      IEXPLORER process on the Processes tab.

      Start IE4.0. Type in the URL for the testPI.html file (e.g.
      http://yourwebserver/testPI.html ). This will start the Plug in.

      The Java console should appear and display something like:


           Java(TM) Plug-in
           Using JRE version 1.1.6
           User home directory = C:\WINNT\Profiles\cnormand
           Proxy Configuration: Manual Configuration
                Proxy:
           http=208.206.247.233:8011;https=208.206.247.233:8011;ftp=208.206.247.233:8011

                Proxy Overrides:

           JAR cache enabled.
           Opening http://naomi/jkit/test.jar proxy=208.206.247.233:8011

      The applet will contain some buttons. Press the button labeled LRC
      (which stands for Large Rows and Columns). Something like the following
      will appear in the Java Console:


           Button pressed: LRC
           About to init Applet
           Initializing Table
           Done Initializing
           Adding component
           test.VarSimple[panel3,0,0,0x0,invalid,layout=java.awt.BorderLayout]
           -> Center
           Resizing to: 400, 400
           Showing...
           Resizing to: 400, 398
           Validating...Thread[AWT-EventQueue-0,5,main] validatedOnce =
           false
           DONE Validating Thread[AWT-EventQueue-0,5,main]
           Orig total=4444152 free=1213864 Now total=6037496 free=1407840
           Memory used (negative means memory returned): 1399368
           Validating...Thread[AWT-EventQueue-0,5,main] validatedOnce =
           false
           DONE Validating Thread[AWT-EventQueue-0,5,main]
           Validating...Thread[AWT-EventQueue-0,5,main] validatedOnce =
           true
           Waiting 30 seconds...

      At which point you will see a partially drawn window on the screen.
      During the 30 second wait, record the total memory usage on the task
      manager. Once the 30 second wait has completed, the following will
      appear:


           Wait done. Performing second validation... Watch the total
           memory grow
           DONE Validating Thread[AWT-EventQueue-0,5,main]
           Resizing to: 400, 379

      The window should be completely drawn and appear with a table widget and
      a few buttons. Now examine the total memory usage from the task
      manager. In most cases, my memory usage jumped 8 MB.

      The method in question is TestExampleFrame.invalidate(). It is being
      called 3 times (not normally a problem). The first two invokations
      appear to be in the same call stack, since the 'validatedOnce' variable
      is still false in the second invokation. The third invokation, however,
      occurs in a separate call stack, since the 'validatedOnce' variable is
      true. The method looks like:


           public void validate() {
                System.out.print("Validating..." +
           Thread.currentThread());
                System.out.println(" validatedOnce = " + validatedOnce);
                if (validatedOnce) {
                     System.out.println("Waiting 30 seconds...");
                     try { Thread.sleep(30000); } catch
           (InterruptedException ie) {}
                     System.out.println("Wait done. Performing second
           validation... Watch the total memory grow");
                }
                super.validate();
                validatedOnce = true;
                System.out.println("DONE Validating " +
           Thread.currentThread());
           }

      The memory increase occurs during the 3rd invokation of the validate
      method.

      The drastic memory increase does NOT appear when running this testcase in
      IE4.0, without the Plug in (execute the html file 'test.html' instead of
      'testPI.html' and follow the same steps).

      An interesting point: when running in IE4.0 without the Plug in, the
      validation method is only called twice. The window is completely drawn
      after the 2nd invalidate.


            myangsunw Mingyao Yang (Inactive)
            mhmccart Mary Mccarthy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: