# Should I usually use destroy()?

**URL:** <https://www.ruby-forum.com/t/should-i-usually-use-destroy/220245>\
**Category:** FXRuby\
**Created:** [June 3, 2012, 7:11pm UTC](https://www.ruby-forum.com/t/should-i-usually-use-destroy/220245 "2012-06-03T19:11:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 3, 2012, 7:11pm UTC](https://www.ruby-forum.com/t/should-i-usually-use-destroy/220245/1 "2012-06-03T19:11:24Z")

</div>

Hi, I’m developing an application with this beautifull framework, had  
read the book by Lyle J. by the way. I’m wondering if I should call  
destroy() in those widgets which I’ll not use anymore.  
Here is the real example: when I push a button, a FXDialogBox object  
raise, it content is dynamic, what I mean is that it content will be  
random, sometimes you will see a bunch of widgets, sometimes you will  
see another different bunch of widgets, the question is: Should I call  
destroy() in that FXDialogBox object?(I will not use the SAME dialog box  
anymore) or ruby will take care of it.  
What I learned reading the book is that the object in the CLIENT SIDE  
will be erased by the Ruby GC when it is unavailable to reach by another  
object or scope in the runtime(classic work of the GC, nothing strange);  
by other side I’m not pretty sure about what happen with the SERVER SIDE  
resource created in the past by that object now erased by the GC, what  
happen with that? it’s erased from the Windows GDI? should I call  
destroy() once I don’t need anymore the group of widgets?  
Hope I was clear in explanation, thanks for your time.

---

<div class="post-metadata">

**Author:** ![DamiSSn\_MSG](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@DamiSSn\_MSG](https://www.ruby-forum.com/u/DamiSSn_MSG)\
**Post date:** [June 17, 2012, 3:31pm UTC](https://www.ruby-forum.com/t/should-i-usually-use-destroy/220245/2 "2012-06-17T15:31:35Z")

</div>

This is the answer by the way…

[Pragmatic Bookshelf: By Developers, For Developers](http://forums.pragprog.com/forums/53/topics/10776)
