-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
generic
-
generic
Name: ssT124754 Date: 01/31/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-beta_refresh)
Java HotSpot(TM) Client VM (build 1.3.0-beta_refresh, mixed mode)
Compile the following program and run it.
import javax.swing.*;
import java.util.*;
public class IntFrame extends JFrame {
public static void main(String[] args) throws Exception {
IntFrame demo = new IntFrame();
}
public IntFrame() throws Exception {
JDesktopPane desktop = new JDesktopPane();
setContentPane(desktop);
for (int i = 0; i < 20; i++) {
JInternalFrame jif = new JF();
desktop.add(jif);
jif.show();
pack();
show();
Thread.sleep(1000);
desktop.remove(jif);
jif.dispose();
System.gc();
System.out.println(i + "disposed");
}
}
}
class JF extends JInternalFrame {
int[] i = new int[1000000];
protected void finalize() {
System.out.println("finalized");
}
}
The output is
0disposed
1disposed
2disposed
3disposed
4disposed
5disposed
6disposed
7disposed
8disposed
9disposed
10disposed
11disposed
12disposed
13disposed
14disposed
Exception in thread "main" java.lang.OutOfMemoryError
<<no stack trace available>>
I think, provided the source and the gc are correct, the JInternalFrame
should get garbage collected before the system runs out of memory.
(Your first answer was, that it does not get gc'ed immediately because
of a weak reference, but this one should be cleared before an
OutOfMemoryError occurs.)
(Review ID: 116124)
======================================================================