http://www.whytheluckystiff.net/ruby/pickaxe/html/ext_ruby.html

This explains how to use Data_Wrap_Struct and how to manage garbage
collection. The issue is not so much preventing garbage collection as
making it possible.