[Mono-list] Embeding Mono. Memory management

Alexander Smirnov smsrecv at ya.ru
Fri Nov 20 08:25:17 EST 2009


But how GC knows when to free such objects? When it frees such objects?
Could GC free the object when I still need it? 
for example

void func() {
  MonoString* str=mono_string_new (domain, "some text");
  /*
   could GC free str before "using str", if no, why?
  */
  // using str
}

thanks

20.11.09, 14:01, "Robert Jordan" <robertj at gmx.net>:

> 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
>  
>  
>  _______________________________________________
>  Mono-list maillist  -  Mono-list at lists.ximian.com
>  http://lists.ximian.com/mailman/listinfo/mono-list
>  
>  

-- 
Alexander Smirnov

Яндекс.Почта. Письма есть. Спама - нет. http://mail.yandex.ru/nospam/sign


More information about the Mono-list mailing list