[Mono-list] Embeding Mono. Memory management

Robert Jordan robertj at gmx.net
Fri Nov 20 08:01:30 EST 2009


Alexander Smirnov wrote:
> Hello 
> 
> I want to use mono embeding. 
> But I don't quite understand how the memory management is done when using mono objects from C code. 
> For example, there is mono_string_new() function which creates a mono string. This string belongs to mono - am I right? 
> So how mono garbage collector knows when to delete the string? 
> Or should I tell it to do that? But I didn't found any function to release mono objects from C, particulary MonoString objects. 

MonoObject and structures derived from them (MonoString, MonoArray, 
etc.) are controlled by the GC even when used in embedding scenarios.
There is no way to free them, because the GC is taking care of
this.

This also means that you cannot store MonoObjects into memory locations
(other than the stack) w/out using GC handles (see mono_gchandle_*
functions).

Robert




More information about the Mono-list mailing list