Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » dispose
dispose [message #466122] Tue, 03 January 2006 10:21 Go to next message
Eclipse UserFriend
Originally posted by: ingo.siebertNOSPAM.cas.de

Hi,

i read the two rules about dispose(), but i'm not quite sure if i
understand it.

I've read, everything i create i must dispose.
But one the other hand, if dispose of a super class is called all the
childs are disposed itself.

For example, i created three editor components(RCP). They a creating
some widgets like labels, tables, ...

Do i have to dispose the widgets in the dispose method of the editor?

It would be very nice if some can explain that to me.
Thanks,

Ingo
Re: dispose [message #466137 is a reply to message #466122] Tue, 03 January 2006 15:56 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
To dispose of any child widgets, it's easiest to call the dispose method of the parent. You don't actually override the dispose method to dispose specific children or any of that jazz. It's all done automatically by the parent. Also, you're absolutely correct that anything you create you should dispose. It should be noted however, that this is rarely an issue with UI widgets as to remove them from the parent you *have* to dispose them (well, or reparent them). The real issues with disposal come in with Font, Color, and Image resources (and once in a while with GC). These are all resources that are generally in limited quantity on the platform and are almost always created by you (as opposed to some parent widget). If you don't dispose if these resources, the world won't come to an end, but you will eat memory like a hog as well as the possibility of crashing your system if you run the app too many times.
Re: dispose [message #466142 is a reply to message #466137] Tue, 03 January 2006 17:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ingo.siebertNOSPAM.cas.de

Thank you for your answer.
Good to hear that disposing isn't so much work as i thought before.

I doesn't quite understand why Font, Color and Image resources are only
in limited quantity available, especially Color, but i know now that i
should dispose that ones myself.

Thanks,

Ingo
Re: dispose [message #466148 is a reply to message #466142] Tue, 03 January 2006 20:23 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

This is because on most systems these are allocated down inside the
operating system and not directly within your code. Operating system
objects typically need to be explicitly disposed. Since the OS is
allocating them they are typically in limited quantities.



Ingo Siebert wrote:
> Thank you for your answer.
> Good to hear that disposing isn't so much work as i thought before.
>
> I doesn't quite understand why Font, Color and Image resources are only
> in limited quantity available, especially Color, but i know now that i
> should dispose that ones myself.
>
> Thanks,
>
> Ingo

--
Thanks,
Rich Kulp
Previous Topic:adding columns to a table in a view at runtime
Next Topic:Is this a resource leak bug?
Goto Forum:
  


Current Time: Thu Dec 05 17:26:58 GMT 2024

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

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

Back to the top