[Mono-list] Embeding Mono. Memory management

Jeffrey Stedfast fejj at novell.com
Fri Nov 20 08:56:32 EST 2009


On 11/20/2009 08:25 AM, Alexander Smirnov wrote:
> 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
>   

You might find this article informative:
http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29

The gist of it is that Mono's GC (which is just Boehm's GC) scans for
references to memory that it has allocated, so as long as your program
has pointers to these objects, the GC will not collect them.

Hope that helps,

Jeff



More information about the Mono-list mailing list