Details

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

      Backports

        Description

        Platform: WindowsNT4.0
        JDK: JDK1.3.1

        Sample program don't release memory. This promblem was checked by using
        OptimizeIt. After sample program started, please click the diplayed box. One
        object don't release memory when other box was selected. After many clicking,
        one object has so many resouce.
        Work around of similar bug "4396433" is applied, but improvement didn't show
        up.

        --------------------------------------------------------------------
        import java.awt.*;
        import java.awt.event.*;
        import java.util.*;
        import javax.swing.*;
        import javax.swing.event.*;
        import javax.swing.tree.*;

        public class TestAction extends JFrame implements TreeSelectionListener{
            Runtime runtime = Runtime.getRuntime();
            JMenu fileMenu = null;
            MyNode root = null;
            DefaultTreeModel treeModel = null;
            JTree tree = null;

            public TestAction(){
        super("TestAction");

        JMenuBar menuBar = new JMenuBar();
        fileMenu = new JMenu("FILE");
        menuBar.add(fileMenu);

        setJMenuBar(menuBar);

        root = new MyNode();
        for(int i = 0; i < 20; i++)
        root.add(new MyNode());

        treeModel = new DefaultTreeModel(root);
        tree = new JTree(treeModel);
        tree.addTreeSelectionListener(this);
        tree.setSelectionRow(0);

        Container content = getContentPane();
        content.setLayout(new BorderLayout());
        content.add(tree);

        addWindowListener(new WindowAdapter(){
        public void windowClosing(WindowEvent e){
        System.exit(0);
        }
        });

        pack();
        setVisible(true);
            }

            public void valueChanged(TreeSelectionEvent e){
        TreePath path = e.getNewLeadSelectionPath();
        Object[] nodes = path.getPath();
        if (nodes[nodes.length - 1] instanceof MyNode){
        MyNode node = (MyNode)nodes[nodes.length - 1];
        fileMenu.removeAll();
        for(int i = 0; i < node.actions.size(); i++)
        fileMenu.add((Action)node.actions.get(0));

        System.gc();
        System.out.println("REBUILD MENU: FREE(" + (double)((double)runtime.freeMemory() / (double)runtime.totalMemory() * 100.0) + ")");
        }
            }

            public static void main(String args[]){
        new TestAction();
            }
        }

        class MyNode extends DefaultMutableTreeNode{
            Vector actions = new Vector();

            MyNode(){
        super("MyNode");
        for(int i = 0; i < 30; i++)
        actions.add(new MyAction());
            }
        }

        class MyAction extends AbstractAction{
            MyAction(){
        super("MyAction");
            }

            public void actionPerformed(ActionEvent e){
            }
        }
        --------------------------------------------------------------------
        masaaki.kamito@Japan 2001-08-07

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  peterz Peter Zhelezniakov (Inactive)
                  Reporter:
                  mkamito Masaaki Kamito (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: