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

JMenu memory leak

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.3.0
    • Fix Version/s: 1.3.1_03
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      03
    • CPU:
      x86
    • OS:
      windows_nt

      Backports

        Description



        Name: yyT116575 Date: 11/14/2000


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

        The attached program includes a JMenuBar with a JMenu in it. Clicking on
        the "Remove" button should cause the JMenuBar and the JMenu to become garbage.
        The JMenuBar does become garbage, but the JMenu does not. I do not have any
        poitners to it, they're all from JDK (BasicMenuUI$PostAction,
        BasicMenuUI$ChangeHandler, SwingPropertyChangeSupport, etc).

        --- code ---
        import javax.swing.*;
        import java.awt.event.*;

        class Test {
          JFrame f;
          JMenuBar mb;
          JMenu menu;
          
          Test () {
            f = new JFrame("TEST");
            mb = new JMenuBar();
            menu = new JMenu("Test Menu");
            mb.add(menu);
            f.setJMenuBar(mb);
            JButton b = new JButton("Remove");
            f.getContentPane().add(b);
            b.addActionListener(new ActionListener () {
                public void actionPerformed (ActionEvent e) {
                  disposeMenu();
                }
              });
            f.pack();
            f.show();
          }

          private void disposeMenu () {
            f.setJMenuBar(null);
            mb.remove(menu);
            menu = null;
            mb = null;
            f.validate();
          }

          public static void main (String[] args) {
            new Test();
          }
        }
        (Review ID: 112246)
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                svioletsunw Scott Violet (Inactive)
                Reporter:
                yyoungsunw Yung-ching Young (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: