The ruby garbage collector.
If you let the ruby garbage collector do all of the work, and you never call malloc or another C function that calls malloc, then your C extension cannot leak memory.