From: Eric Hodel Date: 2012-05-18T07:24:33+09:00 Subject: Re: rb_gc_register_address() or rb_gc_mark()? On May 17, 2012, at 12:31, Hans Mackowiak wrote: > i create an hash from the C-side, mark them with rb_global_variable and > then store my objects into them … > > this protects my objects from being deleted. This is probably wrong. By using rb_global_variable the object can never be reclaimed by the garbage collector. You should either: Return a ruby object to the user that stores your Hash. Use Data_Wrap_Struct/Data_Make_Struct to store your Hash and use rb_gc_mark to indicate it is still alive. Use a constant, class or instance variable on a pre-defined class to store your Hash.