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

Memory Leak with Dialog

XMLWordPrintable

    • rc1
    • x86, sparc
    • linux, solaris_8
    • Verified



      Name: rmT116609 Date: 09/21/2000


      java version "1.3.0beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta_refresh-b09)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode)

      JDialogs get not gc'ed.
      Compile this little program will demonstrate this.
      When running this program on an earlier version of swing the JDialog will
      properly garbage collected.
      This is a serious bug!!! Pleas fix this soon or provid a workaround.
      Any serious program with dialogs will run out of memory very soon!!!!

      import java.awt.event.*;

      import javax.swing.*;

      public class JDialogMemoryBug extends JDialog {

          /** Creates new JDialogMemoryBug */
          public JDialogMemoryBug() {
              JPanel panel = new JPanel();
              JButton closeButton = new JButton("Close");
              panel.add(closeButton);
              closeButton.addActionListener(new ActionListener() {
                  
                  public void actionPerformed(ActionEvent evt) {
                      setVisible(false);
                      dispose();
                  }
              });
              setContentPane(panel);
              setModal(true);
          }

          public void finalize() {
              System.out.println("FINALIZED");
          }
          
          public static void main(String[] args) {
              while (true) {
                  JDialogMemoryBug dialog = new JDialogMemoryBug();
                  dialog.pack();
                  dialog.setVisible(true);
                  dialog = null;
                  System.gc();
              }
          }
      }
      (Review ID: 109890)
      ======================================================================

            prssunw Prs Prs (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: