[Mono-list] lifetime of MonoMethod in mono embedding

ptr2009 ptrajkumar at gmail.com
Wed Nov 18 14:54:43 EST 2009

Robert Jordan wrote:
> ptr2009 wrote:
>> hey all
>>    It seems like when using mono_object_new in an embedded application
>> you
>> are supposed to use mono_gchandle_new to store a handle to the object so
>> that it is not garbage collected when you reference it again. 
>>   1) what is appropriate value of pinned gboolean to be passed to
>> mono_gchandle_new . Does it always need to be passed as TRUE ?
> TRUE is only needed if the object may not be moved after
> you've got a handle for it. With the current GC it doesn't
> matter, but this may change in the future.
>>   2) I also have a call a method on this object handle periodically.  Is
>> it
>> safe to store a pointer to MonoMethod that is returned from
>> mono_class_get_method_from_name in your native code. Is MonoMethod*
>> pointer
>> effected by the garbage collector.  Is there an equivalent of
>> mono_gchandle_new for methods ?
> MonoMethod* is an unmanaged structure. As such it's not GCed and
> there is no "mono_gchandle_new" for it. In general, if an API
> needs some kind of freeing, it will be documented. MonoMethods
> do not need to be freed.
> Robert
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

I did find that a MonoMethod* seemed valid for the lifetime of my
application. Just wanted to verify that it is was indeed the case and I was
not being extremely lucky :)


View this message in context: http://old.nabble.com/lifetime-of-MonoMethod-in-mono-embedding-tp26414091p26414548.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list