diff --git a/ecr/heap_wrapper_struct.ecr b/ecr/heap_wrapper_struct.ecr index e6a9d4a..1a91904 100644 --- a/ecr/heap_wrapper_struct.ecr +++ b/ecr/heap_wrapper_struct.ecr @@ -29,6 +29,9 @@ module <%= namespace_name %> <% if object.boxed? %> def finalize + {% if flag?(:debugmemory) %} + LibC.printf("~%s at %p\n", self.class.name, self) + {% end %} LibGObject.g_boxed_free(<%= type_name %>.g_type, self) end <% end %> diff --git a/spec/boxed_struct_spec.cr b/spec/boxed_struct_spec.cr index 1c60673..96aba5a 100644 --- a/spec/boxed_struct_spec.cr +++ b/spec/boxed_struct_spec.cr @@ -1,4 +1,13 @@ require "./spec_helper" +@[NoInline] +private def create_boxed : Nil + Test::BoxedStruct.return_boxed_struct("hey") +end + describe "Boxed Struct bindings" do + it "doesn't crash on finalize method" do + create_boxed + GC.collect + end end