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

first instance of (J)Applet is not gc'ed

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      02
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        running a JApplet inside java plugin, after a reload,
        the first instance of an JApplet is not gc'ed because of following reference:
        (output of HAT)

        Static reference from sun.awt.image.BufferedImageGraphicsConfig.configs (from class sun.awt.image.BufferedImageGraphicsConfig) :
        --> Instance of [Lsun.awt.image.BufferedImageGraphicsConfig;@0xd086e007 (48 bytes) (Element 1 of Instance of [Lsun.awt.image.BufferedImageGraphicsConfig;:)
        --> sun.awt.image.BufferedImageGraphicsConfig@0x40c21708 (4 bytes) (field bImg:)
        --> sun.awt.image.OffScreenImage@0xf06adc07 (32 bytes) (field c:)
        --> psft.pt75.applet.PanelApplet@0x20fb1e06 (352 bytes)

        although this is not a "leak": there is at most 1 instance of applet that
        stays around, the customer's applet is very big (~4M) so he would like
        to be able to clear any unused instance from memory. he filed an escalation
        for this problem 525433

        BufferedImageGraphicsConfig has static reference to some image.
        one way to get rid of this applet instance is to use some kind of weak
        reference to replace this static reference.

        add in a test case: StaticTest.java, reload the applet and see if
        it prints out "finalized 0"

        import javax.swing.*;
        import java.applet.*;
        import java.util.*;
        import java.awt.*;

        public class StaticTest extends JApplet
        {
            static int counter = 0;
            int myid;
            public void init()
            {
                myid = counter;
                System.out.println( counter++ );
                setSize(400,200);
                getContentPane().add(new JLabel("abc"));
            }
            public void finalize() { System.out.println("finalized " + myid); }
        }

        tao.ma@Eng 2000-07-06

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  tdv Dmitri Trembovetski (Inactive)
                  Reporter:
                  tmasunw Tao Ma (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: