public inbox for java-prs@sourceware.org help / color / mirror / Atom feed
* [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform @ 2004-03-27 12:58 alessandro dot pepi at email dot it 2004-03-27 15:41 ` [Bug libgcj/14751] [win32] " pinskia at gcc dot gnu dot org ` (7 more replies) 0 siblings, 8 replies; 9+ messages in thread From: alessandro dot pepi at email dot it @ 2004-03-27 12:58 UTC (permalink / raw) To: java-prs A program compiled with gcj on Windows platform (i use the thisiscool distribution) never release system handle resources allocated by new threads until the main thread exit. When a compiled java application create a new thread, the system allocate a new thread handle and some other system handles. When the new thread exits the thread handle is released but 3 other system handles (3 per thread) will be released only when application terminate its execution. Below a java test program that i have comiled whith the latest windows thisiscool distribution of gcj: import java.util.*; public class TestThread { public void createThread(final int j){ Runnable run = new Runnable(){ public void run(){ System.out.println("I am thread number "+j); tsleep(2000,null); }; }; try{ new Thread(run).start(); }catch(Exception e){ System.out.println(e.toString()); }; }; public void Test(){ for (int i = 0;i<100;i++){ createThread(i); tsleep(250,null); }; }; public static void tsleep(long t,String s){ if (s!=null) System.out.println(s); try{ Thread.sleep(t); }catch(Exception e){ System.out.println(e.toString()); } }; public static void main(String[] args) { tsleep(5000,"Begin test : look at handles resource on Task Manager before starting "); TestThread test = new TestThread(); test.Test(); tsleep(1000,"executing garbage collector ..."); Runtime.getRuntime().runFinalization(); Runtime.getRuntime().gc(); tsleep(10000,"End test : now look again at handles resource on Task Manager before exiting "); } }; -- Summary: java program compiled with gcj never release system handle resources allocated by new threads on windows platform Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcj AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: alessandro dot pepi at email dot it CC: alessandro dot pepi at email dot it,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=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] java program compiled with gcj never release system handle resources allocated by new threads on windows platform 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it @ 2004-03-27 15:41 ` pinskia at gcc dot gnu dot org 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org ` (6 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-03-27 15:41 UTC (permalink / raw) To: java-prs -- What |Removed |Added ---------------------------------------------------------------------------- Summary|java program compiled with |[win32] java program |gcj never release system |compiled with gcj never |handle resources allocated |release system handle |by new threads on windows |resources allocated by new |platform |threads on windows platform http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] java program compiled with gcj never release system handle resources allocated by new threads on windows platform 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it 2004-03-27 15:41 ` [Bug libgcj/14751] [win32] " pinskia at gcc dot gnu dot org @ 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org ` (5 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-04-29 0:52 UTC (permalink / raw) To: java-prs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-29 00:52 ------- *** Bug 15195 has been marked as a duplicate of this bug. *** -- What |Removed |Added ---------------------------------------------------------------------------- CC| |ovidr at users dot | |sourceforge dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] java program compiled with gcj never release system handle resources allocated by new threads on windows platform 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it 2004-03-27 15:41 ` [Bug libgcj/14751] [win32] " pinskia at gcc dot gnu dot org 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org @ 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org 2004-07-03 22:59 ` pinskia at gcc dot gnu dot org ` (4 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-04-29 0:52 UTC (permalink / raw) To: java-prs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-29 00:52 ------- Confirmed. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Last reconfirmed|0000-00-00 00:00:00 |2004-04-29 00:52:51 date| | Version|unknown |3.4.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] java program compiled with gcj never release system handle resources allocated by new threads on windows platform 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it ` (2 preceding siblings ...) 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org @ 2004-07-03 22:59 ` pinskia at gcc dot gnu dot org 2004-09-10 16:15 ` [Bug libgcj/14751] [win32] thread creation leaks system handle resources ovidr at users dot sourceforge dot net ` (3 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-07-03 22:59 UTC (permalink / raw) To: java-prs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-03 22:59 ------- *** Bug 16342 has been marked as a duplicate of this bug. *** -- What |Removed |Added ---------------------------------------------------------------------------- CC| |efly at javaresearch dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] thread creation leaks system handle resources 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it ` (3 preceding siblings ...) 2004-07-03 22:59 ` pinskia at gcc dot gnu dot org @ 2004-09-10 16:15 ` ovidr at users dot sourceforge dot net 2004-09-10 18:12 ` ovidr at users dot sourceforge dot net ` (2 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: ovidr at users dot sourceforge dot net @ 2004-09-10 16:15 UTC (permalink / raw) To: java-prs ------- Additional Comments From ovidr at users dot sourceforge dot net 2004-09-10 16:15 ------- I think the problem is more than just thread creation. I have ripped out the syncExec code from SWT (Display.syncExec()), and only use three threads in a loop. It requires swt-win32-3062.dll (SWT 3 final) in the directory for PostThreadMessage calls. Handles seem to increase ad infinitum, and memory seems to grow slowly as well (unlike sun's java) but I don't know if it is ever collected. gcj -o threadswitch.exe -fjni --main=org.eclipse.swt.internal.win32.OS OS.java I am using gcj 3.4.1 final (with or without Mohan's patch http://gcc.gnu.org/ml/java/2004-09/msg00048.html) as well as: gcc version 3.5.0 20040730 (experimental) --- package org.eclipse.swt.internal.win32; class OS implements Runnable { public static final native int GetCurrentProcessId(); public static final native int GetCurrentThreadId(); public static final native boolean PostThreadMessageW(int idThread, int Msg, int wParam, int lParam); public static final native boolean PostThreadMessageA(int idThread, int Msg, int wParam, int lParam); public static final int WM_NULL = 0x0; static { System.loadLibrary("swt-win32-3062"); } public static void main(String[] args) { final OS t1 = new OS(); Thread t3 = new Thread() { public void run() { while (true) { try { t1.runAsyncMessages(); Thread.sleep(1); } catch (Exception e) { e.printStackTrace(); } } } }; t3.start(); Thread t2 = new Thread() { public void run() { while (true) { try { System.out.println("Thread: " + Thread.currentThread()); t1.syncExec(t1); Thread.sleep(1); } catch (Exception e) { e.printStackTrace(); } } } }; t2.start(); } Thread thread; Object messageLock = new Object(); RunnableLock[] messages; int messageCount; int threadId; int processId; Thread syncThread; public OS() { threadId = GetCurrentThreadId(); processId = GetCurrentProcessId(); thread = Thread.currentThread(); System.out.println("Thread: " + Thread.currentThread()); } public static final boolean PostThreadMessage(int idThread, int Msg, int wParam, int lParam) { // IsUnicode = !IsWin32s && !IsWin95; // if (IsUnicode) return PostThreadMessageW (idThread, Msg, wParam, lParam); return PostThreadMessageA(idThread, Msg, wParam, lParam); } public void run() { System.out.println("TS: " + Thread.currentThread()); } boolean isValidThread() { return thread == Thread.currentThread(); } void wakeThread() { PostThreadMessage(threadId, WM_NULL, 0, 0); } void addLast(RunnableLock lock) { synchronized (messageLock) { if (messages == null) messages = new RunnableLock[4]; if (messageCount == messages.length) { RunnableLock[] newMessages = new RunnableLock[messageCount + 4]; System.arraycopy(messages, 0, newMessages, 0, messageCount); messages = newMessages; } messages[messageCount++] = lock; if (messageCount == 1) this.wakeThread(); } } protected void syncExec(Runnable runnable) { if (this.isValidThread()) { if (runnable != null) runnable.run(); return; } if (runnable == null) { // display.wake(); return; } RunnableLock lock = new RunnableLock(runnable); /* * Only remember the syncThread for syncExec. */ lock.thread = Thread.currentThread(); synchronized (lock) { addLast(lock); boolean interrupted = false; while (!lock.done()) { try { lock.wait(); } catch (InterruptedException e) { interrupted = true; } } if (interrupted) { Thread.currentThread().interrupt(); } if (lock.throwable != null) { System.err.println("Throwable != null"); } } } boolean runAsyncMessages() { if (messageCount == 0) return false; RunnableLock lock = removeFirst(); if (lock == null) return true; synchronized (lock) { syncThread = lock.thread; try { lock.run(); } catch (Throwable t) { lock.throwable = t; System.err.println("FAILED EXEC"); } finally { syncThread = null; lock.notifyAll(); } } return true; } RunnableLock removeFirst() { synchronized (messageLock) { if (messageCount == 0) return null; RunnableLock lock = messages[0]; System.arraycopy(messages, 1, messages, 0, --messageCount); messages[messageCount] = null; if (messageCount == 0) messages = null; return lock; } } class RunnableLock { Runnable runnable; Thread thread; Throwable throwable; RunnableLock(Runnable runnable) { this.runnable = runnable; } boolean done() { return runnable == null || throwable != null; } void run() { if (runnable != null) runnable.run(); runnable = null; } } } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] thread creation leaks system handle resources 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it ` (4 preceding siblings ...) 2004-09-10 16:15 ` [Bug libgcj/14751] [win32] thread creation leaks system handle resources ovidr at users dot sourceforge dot net @ 2004-09-10 18:12 ` ovidr at users dot sourceforge dot net 2004-09-11 19:14 ` cvs-commit at gcc dot gnu dot org 2004-09-11 19:32 ` pinskia at gcc dot gnu dot org 7 siblings, 0 replies; 9+ messages in thread From: ovidr at users dot sourceforge dot net @ 2004-09-10 18:12 UTC (permalink / raw) To: java-prs ------- Additional Comments From ovidr at users dot sourceforge dot net 2004-09-10 18:12 ------- swt-win32-3062.dll and source are here: ftp://download.eclipse.org/R-3.0-200406251208/swt-3.0-win32.zip -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] thread creation leaks system handle resources 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it ` (5 preceding siblings ...) 2004-09-10 18:12 ` ovidr at users dot sourceforge dot net @ 2004-09-11 19:14 ` cvs-commit at gcc dot gnu dot org 2004-09-11 19:32 ` pinskia at gcc dot gnu dot org 7 siblings, 0 replies; 9+ messages in thread From: cvs-commit at gcc dot gnu dot org @ 2004-09-11 19:14 UTC (permalink / raw) To: java-prs ------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-09-11 19:14 ------- Subject: Bug 14751 CVSROOT: /cvs/gcc Module name: gcc Changes by: membar@gcc.gnu.org 2004-09-11 19:13:51 Modified files: libjava : ChangeLog win32-threads.cc libjava/include: win32-threads.h Log message: PR libgcj/14751 * win32-threads.cc (_Jv_ThreadInitData): Zero out thread handle in newly-allocated _Jv_Thread_t. (_Jv_ThreadDestroyData): Close thread handle. (_Jv_ThreadStart): Remove obsolete comment. Store handle of newly-created thread in _Jv_Thread_t. * include/win32-threads.h: #define WIN32_LEAN_AND_MEAN before including <windows.h> #define _Jv_HaveCondDestroy Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3050&r2=1.3051 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/win32-threads.cc.diff?cvsroot=gcc&r1=1.11&r2=1.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/include/win32-threads.h.diff?cvsroot=gcc&r1=1.9&r2=1.10 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libgcj/14751] [win32] thread creation leaks system handle resources 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it ` (6 preceding siblings ...) 2004-09-11 19:14 ` cvs-commit at gcc dot gnu dot org @ 2004-09-11 19:32 ` pinskia at gcc dot gnu dot org 7 siblings, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-09-11 19:32 UTC (permalink / raw) To: java-prs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-11 19:32 ------- Fixed for 4.0.0. -- What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Target Milestone|--- |4.0.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14751 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-09-11 19:32 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-03-27 12:58 [Bug libgcj/14751] New: java program compiled with gcj never release system handle resources allocated by new threads on windows platform alessandro dot pepi at email dot it 2004-03-27 15:41 ` [Bug libgcj/14751] [win32] " pinskia at gcc dot gnu dot org 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org 2004-04-29 0:52 ` pinskia at gcc dot gnu dot org 2004-07-03 22:59 ` pinskia at gcc dot gnu dot org 2004-09-10 16:15 ` [Bug libgcj/14751] [win32] thread creation leaks system handle resources ovidr at users dot sourceforge dot net 2004-09-10 18:12 ` ovidr at users dot sourceforge dot net 2004-09-11 19:14 ` cvs-commit at gcc dot gnu dot org 2004-09-11 19:32 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).