Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Disposing of resources
Disposing of resources [message #446703] Tue, 30 November 2004 23:59 Go to next message
Max is currently offline MaxFriend
Messages: 28
Registered: July 2009
Junior Member
Okay, this has probably been answered a 100 times before, but I would
still like to know how to handle the following scenarios:

I have a program running in the background with a gui part. I launch the
gui part when necessary by creating a shell, some widgets and some
images etc.

When I dispose of the shell, but the program keeps running, do I need to
dispose the images 'by hand' or is that taken care of automatically?

What about the images if the shell is disposed by the background program
(and thus the jvm) exiting -

Regards
--
Regards Max rotvel AT bolignet-aarhus DOT dk
Re: Disposing of resources [message #446713 is a reply to message #446703] Wed, 01 December 2004 11:58 Go to previous messageGo to next message
Mark McLaren is currently offline Mark McLarenFriend
Messages: 45
Registered: July 2009
Member
I've never had a problem with the JVM not exiting because some widgets
weren't disposed. Can you post a simple snippet?

Max wrote:

> Okay, this has probably been answered a 100 times before, but I would
> still like to know how to handle the following scenarios:

> I have a program running in the background with a gui part. I launch the
> gui part when necessary by creating a shell, some widgets and some
> images etc.

> When I dispose of the shell, but the program keeps running, do I need to
> dispose the images 'by hand' or is that taken care of automatically?

> What about the images if the shell is disposed by the background program
> (and thus the jvm) exiting -

> Regards
Re: Disposing of resources [message #446716 is a reply to message #446703] Wed, 01 December 2004 14:55 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Max,

Disposing of the Shell does not dispose of its contained Images, so you
still need to dispose them afterwards. Ideally this should be done in the
scenario of the program exiting as well, though in practice the native
resource handles will be reclaimed when the jvm exits.

Grant

"Max" <this@address.is.invalid> wrote in message
news:MPG.1c1727b061958c10989683@news.eclipse.org...
> Okay, this has probably been answered a 100 times before, but I would
> still like to know how to handle the following scenarios:
>
> I have a program running in the background with a gui part. I launch the
> gui part when necessary by creating a shell, some widgets and some
> images etc.
>
> When I dispose of the shell, but the program keeps running, do I need to
> dispose the images 'by hand' or is that taken care of automatically?
>
> What about the images if the shell is disposed by the background program
> (and thus the jvm) exiting -
>
> Regards
> --
> Regards Max rotvel AT bolignet-aarhus DOT dk
Re: Disposing of resources [message #446717 is a reply to message #446713] Wed, 01 December 2004 15:01 Go to previous messageGo to next message
Max is currently offline MaxFriend
Messages: 28
Registered: July 2009
Junior Member
Neither have I :-) My question(s) were about the OS resources that you
create yourself (images, fonts etc).

Are they automatically disposed when then jvm exits? (I assume that they
are).

Are such resources automatically disposed when the shell they are added
to is disposed (I assume they are not).

Regards /Max

In article <cokblo$akl$1@www.eclipse.org>, noone@nowhere.com says...
> I've never had a problem with the JVM not exiting because some widgets
> weren't disposed. Can you post a simple snippet?
>
> Max wrote:
>
> > Okay, this has probably been answered a 100 times before, but I would
> > still like to know how to handle the following scenarios:
>
> > I have a program running in the background with a gui part. I launch the
> > gui part when necessary by creating a shell, some widgets and some
> > images etc.
>
> > When I dispose of the shell, but the program keeps running, do I need to
> > dispose the images 'by hand' or is that taken care of automatically?
>
> > What about the images if the shell is disposed by the background program
> > (and thus the jvm) exiting -

--
Regards Max rotvel AT bolignet-aarhus DOT dk
Re: Disposing of resources [message #446722 is a reply to message #446716] Wed, 01 December 2004 16:19 Go to previous messageGo to next message
Max is currently offline MaxFriend
Messages: 28
Registered: July 2009
Junior Member
In article <cokm1s$usb$1@www.eclipse.org>, grant_gayed@ca.ibm.com
says...
> Disposing of the Shell does not dispose of its contained Images, so you
> still need to dispose them afterwards. Ideally this should be done in the
> scenario of the program exiting as well, though in practice the native
> resource handles will be reclaimed when the jvm exits.

Thanks for clearing that up.

Perhaps your answer could be added to the FAQ with an additional link to
http://eclipse.org/articles/swt-design-2/swt-design-2.html for a more
in-depth discussion.

Regards
--
Regards Max rotvel AT bolignet-aarhus DOT dk
Re: Disposing of resources [message #446739 is a reply to message #446703] Thu, 02 December 2004 03:32 Go to previous message
Mani Ghamari is currently offline Mani GhamariFriend
Messages: 33
Registered: July 2009
Member
Hi max,

Your questions are aparently answered!
I don't know if you have any experience with this, yet, if you insist on
freeing all the resources before the jvm exit, you might want to take a look
at ShutdownHooks ( java.lang.Runtime.addShutdownHook(Thread hook) ).

regards,

Mani
"Max" <this@address.is.invalid> wrote in message
news:MPG.1c1727b061958c10989683@news.eclipse.org...
> Okay, this has probably been answered a 100 times before, but I would
> still like to know how to handle the following scenarios:
>
> I have a program running in the background with a gui part. I launch the
> gui part when necessary by creating a shell, some widgets and some
> images etc.
>
> When I dispose of the shell, but the program keeps running, do I need to
> dispose the images 'by hand' or is that taken care of automatically?
>
> What about the images if the shell is disposed by the background program
> (and thus the jvm) exiting -
>
> Regards
> --
> Regards Max rotvel AT bolignet-aarhus DOT dk
Previous Topic:Coming Up "Short" on Result
Next Topic:How to set a TableColumn-type?!?
Goto Forum:
  


Current Time: Fri Apr 19 21:43:37 GMT 2024

Powered by FUDForum. Page generated in 0.03226 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top