i'm not convinced it's to do with 2 GCs, because the following
doesn't work either:

Excel.ApplicationClass appClass =  new Excel.ApplicationClass();
appClass = null;
GC.Collect();
GC.Collect();

-----Original Message-----
From: Murphy, James [mailto:[EMAIL PROTECTED]]
Sent: 20 May 2002 17:14
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] strange behaviour with Garbage Collector


I think the RCW that implements a finalizer would be moved from whatever
generation it was in (probably 0) into the freachable queue on the call to
GC.Collect.  Though you have no outstanding references to the RCW one does
exist in the freachable queue so the GC cannot collect it yet.   The RCW
will have its finalizer called on a background thread and the freachable
queue entry will be removed.  At this point the original object is no longer
reachable so its garbage and will be cleaned up at the next GC.  That's why
it takes 2 GC to collect finalizable types.

Jim

> -----Original Message-----
> From: Sean Greer (SBI-Chico) [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 20, 2002 11:57 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] strange behaviour with Garbage Collector
>
>
> I'm not an expert on GC, but if the RCW has a finalizer wouldn't it be
> promoted to gen 1?  If this is the case it would require a
> second GC to
> fully collect the RCW.  Or maybe I need to re-read Richter's
> chapter on
> GC...
>
> Seang
>
> -----Original Message-----
> From: Howard Bartfield [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 20, 2002 8:46 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] strange behaviour with Garbage Collector
>
>
> even if you run it in debug and stop just after calling
> GC.Collect() ?
>
> if that's the case then i'm confused!
>
> -----Original Message-----
> From: Rama Krishna [mailto:[EMAIL PROTECTED]]
> Sent: 20 May 2002 16:45
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] strange behaviour with Garbage Collector
>
>
> I wrote the same application and it works fine for. Excel
> does go away.
>
> -----Original Message-----
> From: Howard Bartfield [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 20, 2002 11:41 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] strange behaviour with Garbage Collector
>
>
> Hi Jason
>
> yes, calling ReleaseComObject does the job.
>
> however, I'm just concerned to find out why the Garbage Collection
> doesn't work in the first example, but does in the second.
>
> Regards
> Howard.
>
> -----Original Message-----
> From: Jason Bock [mailto:[EMAIL PROTECTED]]
> Sent: 20 May 2002 16:39
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] strange behaviour with Garbage Collector
>
>
> >does anyone have any ideas on the following:
> >
> >if I try this:
> >
> >Excel.ApplicationClass appClass =  new Excel.ApplicationClass();
> >appClass = null; GC.Collect();
> >
> >Excel.exe remains open as a Process in Task Manager.
>
> Have you tried this:
>
> Excel.ApplicationClass appClass =  new
> Excel.ApplicationClass(); //  Use
> appClass... Marshal.ReleaseComObject(appClass);
> appClass = null;
>
> This will release the COM object reference (at least it should).
>
> Regards,
>
> Jason
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET,
> or subscribe to other DevelopMentor lists at
http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to