[Mono-dev] garbage collection and the embedding API

Sebastian Good sebastian at palladiumconsulting.com
Wed Oct 31 14:20:44 EDT 2007


We are writing an extensive set of libraries in .NET and would like to 
expose them to a C++ application. We are using the embedding API, 
exposing thin wrappers of MonoObject* to the C++ program. They will call 
our functions routinely. We have a few questions:

What are the lifetime rules for a MonoObject* created with 
mono_object_new? Is there a corresponding free that needs to be called? 
I understand that within the JIT's heaps, garbage collection takes care 
of such issues, but when a CIL pointer "escapes" into the C++ world, I  
am having trouble finding documentation describing what to do. I 
understand it is possible to "pin" these MonoObject*s so they don't move 
around, but I assume this is unnecessary until a Compacting GC is 
actually released.

Experimentation suggests that one can indeed be careless with these 
pointers and not suffer a memory leak, but I'd like to have a firm 
understanding.

 From the discussion at 
http://www.mono-project.com/Mono:Runtime#Garbage_Collection it seems 
like  the unmanaged C++ heap is not scanned but it seems to me like it 
is. Does the GC linked in with mono replace the default new() or malloc 
operators?

Many thanks

Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3301 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071031/d7e10720/attachment.bin 


More information about the Mono-devel-list mailing list