[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: javaw.exe keeps running in Windows

Hi Steve. Yes, confirmed. Our problem was a combination of JFace and a GUI designer which is now fixed. To summarize, main method was missing "Display.getCurrent().dispose()" below:

public static void main(String args[]) {
 try {
   MainWindow window = new MainWindow();
   // (MainWindow is an ApplicationWindow)
   window.setBlockOnOpen(true);
   Display.getCurrent().dispose();
 } catch (Exception e) {
   e.printStackTrace();
 }
}





Steve Northover wrote:

Ok, it was a combination of the GUI builder and JFace.  I just want to
confirm with you that SWT doesn't do anything special to keep running.

"Bill Ewing" <ewing@xxxxxxxxx> wrote in message
news:ct442e$t3m$1@xxxxxxxxxxxxxxxxxx
Bill Ewing wrote:

> Steve Northover wrote:

>> The java VM will not keep running if you fail to dispose an SWT
resource.
>> Are you exiting from your event loop?

>> "Bill Ewing" <ewing@xxxxxxxxx> wrote in message
>> news:csrshl$asq$1@xxxxxxxxxxxxxxxxxx
>>> In Task Manager, you see an instance of javaw.exe (Windows' jvm
launcher)
>>> appear when you start eclipse. We see another instance appear when we
run
>>> our JFace app (either under eclipse or standalone).
>>>
>>> After exiting our app, its javaw.exe does not disappear from Task
Manager.
>>>  They pile up, one for each run.  Eventually, system problems begin to
>>> occur.  Plus, when you try to shut down windows, you get all of these
>>> instances not responding to windows.
>>>
>>> It sure sounds like a memory leak, or a failure to dispose a system
>>> resource, such as a non standard color.
>>>
>>> But, we've scoured our app and commented out all such Color creations.
We
>>> don't do anything with fonts, so we're out of ideas as to what would
cause
>>> this problem.  We have verified that this problem does not occur with
>>> simplistic apps.
>>>
>>> Anyone have any ideas on...?
>>>  1. What our problem is
>>>  2. Strategies for troubleshooting
>>>

> Thank you for taking the time to post, Steve.  The information in your
> response is valuable to us.

> We are using JFace. Specifically, we have an ApplicationWindow class
that
> contains a main method.  So, I believe handling the event loop is
> automatically done by ApplicationWindow-- it's buried and not available
> for us to see (until we figure out how to attach source and JavaDoc to
> libs we use).

> What would you suggest we look at next?

> I was in the process of commenting out chunks of the program, piece by
> piece until the zombie javaw.exe no longer hangs around in Task Manager.

> But now, the knowledge that failure to dispose() would not cause this
> problem makes us wonder just what sort of problem we are chasing.

> Our main method looks like the following.  It was auto-generated by the
> GUI builder available from swt-designer.com.

> public static void main(String args[]) {
> try {
> MainWindow window = new MainWindow();
> window.setBlockOnOpen(true);
> window.open();
> } catch (Exception e) {
> e.printStackTrace();
> }
> }


OK, it looks like we were not dispose'ing Display. Thank you Bahram, for suggesting that earlier.

The reason that this stumped us is that all of the code is autogenerated
by a GUI designer tool that we assumed worked.  We've contacted the
manufacturer (who sent us here).

Our new main method now looks like below.

public static void main(String args[]) {
try {
MainWindow window = new MainWindow();
window.setBlockOnOpen(true);
Display.getCurrent().dispose();
} catch (Exception e) {
e.printStackTrace();
}
}