Eric Hodel wrote in post #1015428:
> On Aug 6, 2011, at 10:08 PM, Tridib Bandopadhyay wrote:
>>> if you use
>>> Data_Wrap_Struct(klass, 0, 0, ptr)
>>> the pointer will not be deleted or freed
>>
>> So will it make Memory Leak..!!!!
>
> No.  If your object can be freed with free() then everything is fine.
> If your object needs to do special things then implement a custom free
> function.
>

Yeah thats what i am trying to do implement my custom free function.


> Ruby will collect the ruby objects inside your pointer when the GC knows
> it is OK provided you implement a mark function.  You should have
> something like this:
>
> static void
> my_mark(my_pointer *ptr) {
>   rb_gc_mark(ptr->ruby_object);
> }
>
> Data_Wrap_Struct(klass, my_mark, -1, ptr);

Ok even if i make my own mark function will the GC keep track of the 
pointer and the object behind it.

Secondly, the object which is been marked by my custom function will it 
be deleted by GC or by my own custom free function.

-- 
Posted via http://www.ruby-forum.com/.