[Mono-dev] GC.Collect() CLR<>Mono difference.

Rodrigo Kumpera kumpera at gmail.com
Thu Jan 8 15:44:30 EST 2009


On Thu, Jan 8, 2009 at 6:05 PM, BGB <cr88192 at hotmail.com> wrote:

>
> ----- Original Message -----
> From: "Sunny" <sloncho at gmail.com>
> To: <mono-devel-list at lists.ximian.com>
> Sent: Friday, January 09, 2009 3:50 AM
> Subject: Re: [Mono-dev] GC.Collect() CLR<>Mono difference.
>
>
> > On Thu, Jan 8, 2009 at 11:45 AM, Sunny <sloncho at gmail.com> wrote:
> >>
> >> According to this:
> >> <
> http://msdn.microsoft.com/en-us/library/system.weakreference(VS.80).aspx<http://msdn.microsoft.com/en-us/library/system.weakreference%28VS.80%29.aspx>
> >
> >>
> >> IsAlive becomes false after the finalizer is done. It may be so, that
> >> under mono your call to IsAlive is made before the finalizer is
> >> called. Try with GC.WaitForPendingFinalizers() before the check.
> >>
> >
> > Hmmm, I just tried it under mono, it still outputs True. Looks like a
> bug.
> >
>
> possible factor:
> references to 'obj' still exist, and are lingering on the stack, ...
>
> so, with a precise GC, the only reference which can exist is the weak
> reference;
> but with a conservative GC (such as Boehm), any lingering references are
> still good.
>
> (note: it appears to me like the project is implementing / has implemented
> an optional precise GC, but I don't know the status, ...).
>
>
> so, the GC runs, and maybe it finds a reference still on the stack
> somewhere?...
> ok then, the object is not collected, and thus no need for the weak ref to
> report a change...
>
>
> I could be wrong though...
>
>
You are correct, this is exactly what happens on this case. The object still
reachable to the conservative GC mono uses.
Our precise GC is still in development.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090108/f101c092/attachment.html 


More information about the Mono-devel-list mailing list