[Mono-list] Embeding Mono. Memory management
    Alexander Smirnov 
    smsrecv at ya.ru
       
    Fri Nov 20 09:07:50 EST 2009
    
    
  
yes, I know that t frees them, when no other managed reference is pointing. 
But right after I create a string using: MonoString* str=mono_string_new (domain, "some text"); 
no managed references point to this string because MonoString* str is not a manged reference. 
So can GC delete "str" right after mono_string_new? 
thanks for your help
20.11.09, 14:56, "Robert Jordan" <robertj at gmx.net>:
> Alexander Smirnov wrote:
>  > But how GC knows when to free such objects? When it frees such objects?
>  
>  It frees them, when no other managed reference is pointing
>  to them.
>  
>  > 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
>  > }
>  
>  
>  If you want to use "str" after func () in unwound, then
>  you have to obtain a gchandle for "str". See Mono's
>  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