🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12518

Memory leak with Jdk 1.2

#12518
From: Benoit Sibold
Date: Thu, 17 Dec 1998 00:00
71 lines
2847 bytes
We have developped a big applet(product) with Jdk 1.2 (Swing 1.1)
with a lot of JInternal Frame. As we open the JInternal Frame and
close them : THE MEMORY IS NEVER RELEASED and raises therefore.
We must close Netscape and rerun the applet all 5mn

There is a sample applet code there show the problem using jdk 1.2

package untitled12;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class Test extends JApplet {
  boolean isStandalone = false;
  int counter = 1;
  JButton makeButton = new JButton("Make");
  JButton clearButton = new JButton("Clear");
  JPanel buttonPanel = new JPanel();
  JDesktopPane displayPanel = new JDesktopPane();

  public Test() {
  }
  public void init() {
    try {
    jbInit();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    this.setSize(400, 300);
    this.getContentPane().setLayout(new BorderLayout());
    makeButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        button_actionPerformed(e);
      }
    });
    clearButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        clearButton_actionPerformed(e);
      }
    });
    this.getContentPane().add(buttonPanel, BorderLayout.NORTH);
    this.getContentPane().add(displayPanel, BorderLayout.CENTER);
    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.add(makeButton, BorderLayout.WEST);
    buttonPanel.add(clearButton, BorderLayout.EAST);
  }
  void button_actionPerformed(ActionEvent e) {
    for (int i = 0; i <= 9; i++) {
      JInternalFrame frame = new JInternalFrame("Frame #" + counter++, false,
false, false, false);
      JButton frameButton = new JButton("Frame button");
      frame.getContentPane().add(frameButton);
      displayPanel.add(frame);
      frame.pack();
      frame.show();
    }
  }

  void clearButton_actionPerformed(ActionEvent e) {
    JInternalFrame list[] = displayPanel.getAllFrames();
    for (int i = 0; i < list.length; i++)
      list[i].dispose();
    displayPanel.repaint();
    counter = 1;
  }
}
Technical Details
Message-ID: <3678D60A.54CFEE98@mhinformatics.ch>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <367632FD.E9919BD7@advs2.gm.fh-koeln.de> <3676914E.9874CD28@inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,a03ec11fedbe6399
X-Google-Attributes: gid111d45,public
From: Benoit Sibold <benoit.sibold@mhinformatics.ch>
Subject: Memory leak with Jdk 1.2
Date: 1998/12/17
Message-ID: <3678D60A.54CFEE98@mhinformatics.ch>
X-Deja-AN: 423198645
Content-Transfer-Encoding: 7bit
References: <367632FD.E9919BD7@advs2.gm.fh-koeln.de> <3676914E.9874CD28@inprise.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing