-
Bug
-
Resolution: Fixed
-
P4
-
1.2.2_003, 1.2.2_005
-
005
-
x86, sparc
-
solaris_7, windows_nt
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2030402 | 1.4.0 | David Mendenhall | P4 | Resolved | Fixed | beta |
JDK-2030401 | 1.3.1 | David Mendenhall | P4 | Resolved | Fixed | 1.3.1 |
JDK-2030400 | 1.3.0_02 | David Mendenhall | P4 | Closed | Fixed | 02 |
I have a customer that is still seeing a JNI Global Reference to his
unreferenced objects when using JDK1.2.2_003 that has the fix for bug
4224888. I have tested the sample code below with JDK1.2.2_003
the memory leak still present.
TestCase:
import java.awt.*;
import java.awt.dnd.*;
import java.awt.dnd.peer.*;
import java.awt.event.*;
import java.awt.peer.*;
import javax.swing.*;
public class bugDropTargetLeak extends JFrame
{
DropTarget _dt;
public bugDropTargetLeak()
{
super("Test Window");
_dt = new DropTarget(this, null);
setSize(400, 400);
}
protected void processWindowEvent(WindowEvent we)
{
if (we.getID() == WindowEvent.WINDOW_CLOSING)
{
System.out.println("window closing...");
if (_dt != null)
{
_dt.setComponent(null);
// The following is to workaround the bug in removeDropTarget(), i.e.
// we need to call it twice for it to invoke the native
// removeNativeDropTarget(). getPeer() is a deprecated method, but
// it's the only workaround I know of.
((DropTargetPeer)getPeer()).removeDropTarget(_dt);
// Clear out the variable just so we have less clutter when analyzing
// using HAT.
_dt = null;
}
dispose();
}
super.processWindowEvent(we);
}
public static void main(String[] args)
{
JFrame f = new JFrame("Main Window");
Container cp = f.getContentPane();
JButton b = new JButton("Click me to launch a leaked window");
f.getContentPane().add(b, "North");
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
(new bugDropTargetLeak()).setVisible(true);
}
});
b = new JButton("gc()");
f.getContentPane().add(b, "South");
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.out.print("Calling system.gc() and System.runFinalization(): ");
System.gc();
System.out.print(".");
System.gc();
System.out.print(".");
System.runFinalization();
System.out.print(".");
System.gc();
System.out.print(".");
System.gc();
System.out.print(".");
System.runFinalization();
System.out.print(".");
System.gc();
System.out.print(".");
System.gc();
System.out.println(" done");
}
});
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
f.pack();
f.setVisible(true);
}
}
unreferenced objects when using JDK1.2.2_003 that has the fix for bug
4224888. I have tested the sample code below with JDK1.2.2_003
the memory leak still present.
TestCase:
import java.awt.*;
import java.awt.dnd.*;
import java.awt.dnd.peer.*;
import java.awt.event.*;
import java.awt.peer.*;
import javax.swing.*;
public class bugDropTargetLeak extends JFrame
{
DropTarget _dt;
public bugDropTargetLeak()
{
super("Test Window");
_dt = new DropTarget(this, null);
setSize(400, 400);
}
protected void processWindowEvent(WindowEvent we)
{
if (we.getID() == WindowEvent.WINDOW_CLOSING)
{
System.out.println("window closing...");
if (_dt != null)
{
_dt.setComponent(null);
// The following is to workaround the bug in removeDropTarget(), i.e.
// we need to call it twice for it to invoke the native
// removeNativeDropTarget(). getPeer() is a deprecated method, but
// it's the only workaround I know of.
((DropTargetPeer)getPeer()).removeDropTarget(_dt);
// Clear out the variable just so we have less clutter when analyzing
// using HAT.
_dt = null;
}
dispose();
}
super.processWindowEvent(we);
}
public static void main(String[] args)
{
JFrame f = new JFrame("Main Window");
Container cp = f.getContentPane();
JButton b = new JButton("Click me to launch a leaked window");
f.getContentPane().add(b, "North");
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
(new bugDropTargetLeak()).setVisible(true);
}
});
b = new JButton("gc()");
f.getContentPane().add(b, "South");
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.out.print("Calling system.gc() and System.runFinalization(): ");
System.gc();
System.out.print(".");
System.gc();
System.out.print(".");
System.runFinalization();
System.out.print(".");
System.gc();
System.out.print(".");
System.gc();
System.out.print(".");
System.runFinalization();
System.out.print(".");
System.gc();
System.out.print(".");
System.gc();
System.out.println(" done");
}
});
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
f.pack();
f.setVisible(true);
}
}
- backported by
-
JDK-2030401 Another java.awt.dnd.DropTarget causing JNI Global Reference leak?
- Resolved
-
JDK-2030402 Another java.awt.dnd.DropTarget causing JNI Global Reference leak?
- Resolved
-
JDK-2030400 Another java.awt.dnd.DropTarget causing JNI Global Reference leak?
- Closed
- duplicates
-
JDK-4326731 Another java.awt.dnd.DropTarget causing JNI Global Reference leak?
- Closed
- relates to
-
JDK-4343272 Yet another java.awt.dnd.DropTarget causing JNI Global Reference leak?
- Resolved
-
JDK-4224888 java.awt.dnd.DropTarget causing JNI Global Reference leak?
- Closed
(1 relates to)