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

Memory leaks in AWT when interacting with MOTIF

    Details

    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Backports

        Description

        (1) Working environments
        OS : Solaris2.5.1 Japanese version
        JRE : JRE1.1.6
        Window : CDE

        A Java source named ShowFrame.java is attached for reproducing the phenomenon.

        (2) Phenomenon
        The memory size of the jre process increases without any limitation.

        [Step 1] Runn ShowFrame.class.
                  " jre ShowFrame"
        [Step 2] Push [Auto Excute] button
        [Step 3] Even there is a dipose method being called,
                 the memory is not freed.
                 And so the memory size of the jre process grows
                 without any limitation.
                 
                 The memory size can be checked by command below.
                 ps -u usrname -o pmem,fname | grep jre

        -------- ShowFrame.java ---------
        import java.awt.*;
        import java.awt.event.*;

        public class ShowFrame extends Frame implements ActionListener{
        public Button button1;
        public Button button2;
        public Button button3;
        public Button button4;
        public NewFrame newframe=null;

        public ShowFrame(){
        setSize(500,300);
        setLayout(null);

        button1 = new Button("Display");
        button1.setSize(100,40);
        button1.setLocation(10,200);
        button1.addActionListener(this);
        add(button1);

        button2 = new Button("Erase");
        button2.setSize(100,40);
        button2.setLocation(120,200);
        button2.addActionListener(this);
        add(button2);

        button3 = new Button("Auto Excute");
        button3.setSize(100,40);
        button3.setLocation(230,200);
        button3.addActionListener(this);
        add(button3);

        button4 = new Button("End");
        button4.setSize(100,40);
        button4.setLocation(340,200);
        button4.addActionListener(this);
        add(button4);

        setVisible(true);
        }
        public void actionPerformed(ActionEvent e){
        if(e.getSource() == button1){
        if(newframe != null){
        return;
        }
        newframe = new NewFrame();
        }
        if(e.getSource() == button2){
        if(newframe == null){
        return;
        }
        newframe.dispose();
        newframe=null;
        }
        if(e.getSource() == button3){
        new AutoExec(this);
        }
        if(e.getSource() == button4){
        System.exit(0);
        }
        }


        static public void main(String str[]){
        new ShowFrame();
        }
        }
        class NewFrame extends Frame{

        public NewFrame(){
        setSize(100,100);
        setBackground(Color.red);
        setLayout(null);
        setVisible(true);
        }
        }

        class AutoExec extends Thread{
        private ShowFrame sf;
        public AutoExec(ShowFrame sf){
        this.sf = sf;
        this.start();
        }
        public void run(){
        for(int i = 0;i < 2002;i++){
        try{
        sleep(1000);
        if(i % 2 == 0){
        if(this.sf.newframe != null){
        continue;
        }
        this.sf.newframe = new NewFrame();
        }
        else{
        if(this.sf.newframe == null){
        continue;
        }
        this.sf.newframe.dispose();
        this.sf.newframe=null;
        }
        }
        catch(Exception e){
        System.out.println(e);
        System.exit(1);
        }
        if(i % 200 == 0){
        System.out.println(Integer.toString(i+1));
        }

        }
        }
        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  myangsunw Mingyao Yang (Inactive)
                  Reporter:
                  duke J. Duke (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: