So I have an applications I support that has been randomly crashing, but is also stuck at an old Ruby and Ruby/Gnome2 build. But my question should bypass that with "how should I do this, regardless of versions"  My question is, basically, good form to destroy things you create, or rely on the garbage collector? Here's the SegV problem I am having...

 So in my case, I am doing the following(yes, I know Canvas is depricated but this could apply to any GUI thing you do a signal_connect on.

spanPoly =…)

spanPoly.signal_connect('event') do |item, event|



Ruby "randomly" is  Seg Faulting with the following, (it does produce a very non helpful core file).

somefile.rb:558: warning: instance variable holder not initialized

somefile.rb:558: [BUG] Segmentation fault

The line 558 is the signal_connect line above. I add those objects to an array, and updated a view. At times they are destroyed. 

My guess at what is happening, is I have destroyed the object. But something is causing that signal_connect handler to run, but crashes Ruby, as its been destroyed. The "instance variable holder not initialized" is a clue to me I think.

In my code, should I really try to do a "signal_handler_disconnect" for that action before I destroy it? Like

Create it like this:

spanPoly =…)

spanPolyEventId = spanPoly.signal_connect('event') do |item, event|




Destroy it like this:



Is this maybe just good form? Trying to explicitly delete what you have "newed".