Name: vi73552 Date: 03/29/99
I filed this bug on 28 January 1999. I'm refiling it as I haven't heard back from Vasya (for almost 1 month now) with regards to why he thought the bug I reported is a duplicate of bug 4109789. I'm not sure what else to do other than to refile this. I need to make sure that this one is not overlooked for the next JDK 1.2 release. Please note that the bug was originally found in JDK 1.2 FCS and bug 4109789 which Vasya said was the same bug was marked as fixed in JDK 1.2 Beta 4. Please see the included e-mail below for more detail. The original bug report is provided again below after the included e-mail.
Please let me know if you have further questions. Without this fix, DnD on Win32 is almost useless for real applications.
>From: "Paul Tjahjadi" <###@###.###>
>Subject: Re: (Review ID: 53371) java.awt.dnd.DropTarget causing JNI Global Reference leak
>Date: Tue, 09 Mar 1999 20:28:57 PST
>can you please let me know why bug 4109789 is saying that the bug was
>fixed in JDK 1.2 Beta 4? The memory leak that I found is in the FCS
>release of JDK 1.2 (which I assume is newer than Beta 4?). So I'm not
>sure I understand how the bug report I submitted could be a duplicate if
>it's still a problem in JDK 1.2 FCS?
>>From: vasya <###@###.###>
>>Subject: Re: (Review ID: 53371) java.awt.dnd.DropTarget causing JNI
>Global Reference leak?
>>Date: Mon, 8 Mar 1999 20:50:39 -0800
>>You have submitted a bug that is a duplicate of Bug Id: 4109789
>>This bug may or may not be listed at the following web sites:
>>Bug information is available through the Java Developer Connection.
>>Thank you for providing us with additional information that can be used
>>in the resolution of this bug.
>>----------------- Original Bug Report-------------------
>>id : 53371
>>category : java
>>subcategory : drag&drop
>>type : bug
>>synopsis : java.awt.dnd.DropTarget causing JNI Global Reference leak?
>>comments : (company - , email - ###@###.###)
>>workaround : None that I know of.
>>cust_name : PTjahjadi
>>cust_email : ###@###.###
>>company : other
>>release : 1.2
>>hardware : x86
>>OSversion : win_nt_4.0
>>status : Deleted
>>delReason : Duplicate
>>priority : 4
>>bugtraqID : 4109789
>>dateCreated : 1999-01-28 16:36:06.0
>>dateEvaluated : 1999-02-01 11:41:22.0
Original bug report:
it seems that the DropTarget addition and removal procedure in JDK 1.2 is causing a JNI Global Reference leak. Below is a simple test case which shows the problem. Please let me know if you know of any workarounds for it.
// BEGIN --- bugDropTargetLeak.java
* This simple Java application shows the memory leak that's caused due to a
* JNI Global Reference when a DropTarget's component is set. It seems that
* removeNativeDropTarget() is not properly cleaning up the global reference.
* To reproduce the problem, you will need to run the application like this on
* Windows (assuming c:\jdk1.2 is your installation folder for JDK 1.2 FCS):
* c:\jdk1.2\bin\java -Xnoclassgc -Xrunhprof:file=dump.hprof,format=b bugDropTargetLeak
* After the application has started, follow these steps:
* 1. Hit the `gc()' button two or three times.
* 2. Go to the Java console and hit Ctrl-Break to dump the heap.
* 3. Hit the `Click me to launch a leaked window' button which would create
* a JFrame and attach a DropTarget to it.
* 4. Close the JFrame (either by using Alt-F4 or clicking on the X button on
* the title bar).
* 5. Hit the `gc()' button two or three times again.
* 6. Go to the Java console and hit Ctrl-Break to get the second heap dump.
* 7. Quit the application.
* 8. Start the HAT server using something like:
* java -mx1004m hat.Main -port=7007 -baseline=dump.hprof:1 dump.hprof:2
* If you drill down on the info for the instance of bugDropTargetLeak,
* you'll see something like:
* JNI Global References
* JNI Global Reference :
* --> bugDropTargetLeak@0x4004a000[new] (264 bytes)
* This analysis concurs with the one OptimizeIt 3.0 shows after following
* the same steps shown above.
public class bugDropTargetLeak extends JFrame
_dt = new DropTarget(this, null);
protected void processWindowEvent(WindowEvent we)
if (we.getID() == WindowEvent.WINDOW_CLOSING)
if (_dt != 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.
// Clear out the variable just so we have less clutter when analyzing
// using HAT.
_dt = null;
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");
public void actionPerformed(ActionEvent ae)
b = new JButton("gc()");
public void actionPerformed(ActionEvent ae)
System.out.print("Calling system.gc() and System.runFinalization(): ");
public void windowClosing(WindowEvent we)
// END --- bugDropTargetLeak.java
(Review ID: 56228)