[Bug java/15195] New: [win32] gcj leaks handles and memory until it crashes
ovidr at users dot sourceforge dot net
gcc-bugzilla@gcc.gnu.org
Thu Apr 29 01:05:00 GMT 2004
gcc version 3.4.0 20040316 & SWT 3.0M8 on WinXP.
> gcj --main=HorribleLeaks HorribleLeaks.java libswt.a -I swt.jar
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class HorribleLeaks {
public static int DELAY = 1;
public static int cnt;
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(400, 400);
shell.open();
Thread t = new Thread() {
public void run() {
for (;;) {
display.syncExec(new Runnable() {
public void run() {
if (++cnt % 10000 == 0)
System.out.println(cnt);
}
});
}
}
};
t.setDaemon(true);
t.start();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Enable: Windows Task Manager ->View->Handle Count
Running this program will show in TaskManager that handles grow to over 2
million and memory increases continually until the above application crashes
with this error:
---
libgcj failure: CreateEvent() failed
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
---
see "org.eclipse.swt.widgets.Synchronizer.java" for the syncExec code. This
problem only exhibits itself when you run display.syncExec from a thread other
than the gui thread and therefore it is forced to switch running threads
before executing the run() method.
In a normal app, handles and memory increase slowly over time but this app's
for loop displays the problem immediately.
The app works fine in SUN's java with consistent memory use and handles.
--
Summary: [win32] gcj leaks handles and memory until it crashes
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ovidr at users dot sourceforge dot net
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15195
More information about the Gcc-bugs
mailing list