# Patch: crash during GC when using combo, listbox

**URL:** <https://www.ruby-forum.com/t/patch-crash-during-gc-when-using-combo-listbox/228266>\
**Category:** wxRuby\
**Created:** [April 16, 2013, 2:06am UTC](https://www.ruby-forum.com/t/patch-crash-during-gc-when-using-combo-listbox/228266 "2013-04-16T02:06:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [April 16, 2013, 2:06am UTC](https://www.ruby-forum.com/t/patch-crash-during-gc-when-using-combo-listbox/228266/1 "2013-04-16T02:06:35Z")

</div>

Hi all, I feel like I may have written about this before, apologies if  
so.

I recently started getting “object allocation during garbage collection  
phase” with wxruby on linux. I traced the problem to GetCount() being  
called on list and combo boxes during the GC’s mark phase. Since the  
GetCount() method has a director, the C++ call triggers a ruby call that  
then allocates a ruby object to store the result, triggering the error.

This patch just disables the director on GetCount(), but that also means  
that this method can’t be overriden in Ruby.

I’m also not sure why this just started happening to me. I did shuffle  
around some code that may have caused a GC where there wasn’t one  
before,  
but surely every GC should trigger this problem if my description of the  
cause is right?

# Index: swig/shared/control\_with\_items.i

— swig/shared/control\_with\_items.i (revision 2115)  
+++ swig/shared/control\_with\_items.i (working copy)  
@@ -13,6 +13,7 @@  
%feature(“nodirector”) \*::GetClientObject(int n) const;  
%ignore \*::SetClientObject(int n, wxClientData \* data);  
%feature(“nodirector”) \*::SetClientObject(int n, wxClientData \* data);  
+%feature(“nodirector”) \*::GetCount() const;

%{  
extern swig\_class cWxControlWithItems;
