Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » To dispose or not to dispose
To dispose or not to dispose [message #447987] Wed, 22 December 2004 15:41 Go to next message
Phill Perryman is currently offline Phill PerrymanFriend
Messages: 214
Registered: July 2009
Senior Member
<br><font size=1 face="sans-serif">I have a scrolled composite and have done a setinput with a composite to scroll. When a certain selection event happens I create a new composite and set the input of the scrolled composite to that.</font>
<br>
<br><font size=1 face="sans-serif">Question is eclipse says that widgets created with a parent are disposed by the system when the parent is disposed. In my case the parent scrolled composite is not disposed and there could be a lot of selection events (circa 200) with say 20 widgets on each composite, does this mean there will be 4000 widgets hanging around until the scrolled composite is disposed.</font>
<br>
<br><font size=1 face="sans-serif">Will the scrolled composite dispose of the old input when a new setinput is done, is it safe for me to dispose of them or do I just leave them all hanging around until the scrolled composite is disposed when the view closes.</font>
<br>
<br>
Re: To dispose or not to dispose [message #448006 is a reply to message #447987] Thu, 23 December 2004 17:32 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Phill,

In your scenario you could be looking at a lot of widgets hanging around,
because since they are all descendents of the ScrolledComposite, they will
not be auto-disposed until the ScrolledComposite is disposed. You may wish
to dispose() of a Composite once it loses its status as the
ScrolledComposite's current content, especially if you know that it will not
be needed again (ie.- you're not likely to use it again as an argument for
ScrolledComposite.setContent(...)). This should be safe to do.

Grant
_______________
<Phill_Perryman@Mitel.COM> wrote in message
news:cqc4jb$h4d$1@www.eclipse.org...

I have a scrolled composite and have done a setinput with a composite to
scroll. When a certain selection event happens I create a new composite and
set the input of the scrolled composite to that.

Question is eclipse says that widgets created with a parent are disposed by
the system when the parent is disposed. In my case the parent scrolled
composite is not disposed and there could be a lot of selection events
(circa 200) with say 20 widgets on each composite, does this mean there will
be 4000 widgets hanging around until the scrolled composite is disposed.

Will the scrolled composite dispose of the old input when a new setinput is
done, is it safe for me to dispose of them or do I just leave them all
hanging around until the scrolled composite is disposed when the view
closes.
Re: To dispose or not to dispose [message #448022 is a reply to message #448006] Fri, 24 December 2004 11:31 Go to previous messageGo to next message
Phill Perryman is currently offline Phill PerrymanFriend
Messages: 214
Registered: July 2009
Senior Member
<br><font size=1 face="sans-serif">Thanks, I have added my own call to dispose after the set input. I have checked all the logs and could not find any errors about access to disposed widgets so it seems ok.</font>
<br>
<br><font size=1 face="sans-serif">Thanks for the help.</font>
Re: To dispose or not to dispose [message #448145 is a reply to message #448022] Mon, 03 January 2005 18:19 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

You may want to try:

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/dev.html#tools

And use the SLEAK tool. This will tell you if you have any SWT resources
that aren't being disposed that should of been.


--
Thanks,
Rich Kulp
Previous Topic:my java code together ve code
Next Topic:should I dispose of a font when...
Goto Forum:
  


Current Time: Thu Mar 28 17:58:22 GMT 2024

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

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

Back to the top