Thanks for the feedback.
I'm only talking about a "Release" build.
Yes, I would like the GC to collect unreferenced objects because if there is
not reference, then I cannot inspect it so what is the point. Also, how can
one inspect variables of a "Release" build anyway? I posted the following
to microsoft.public.vsnet.debugging.
#### BEGINNING OF MY PRIOR POST ####
I think I have figured it out. I _think_ Visual Studio 2003 is holding a
reference to reference types that are directly assigned to variables of a
method even if out of scope. The only exception is in a "Release" build and
the application is started without debugging. The code below is a simple
example of this behavior.
using System;
class Class1
{
[STAThread]
static void Main(string[] args)
{
WeakReference wr = null;
for (int i=0; i<1; ++i)
{
Uri uri = new Uri("http://domain.com");
wr = new WeakReference(uri);
}
System.GC.Collect();
Console.WriteLine(String.Format("IsAlive: {0}", wr.IsAlive));
Console.ReadLine();
}
}
[quoted text, click to view] "Phil Wilson" <pdjwilson@nospam.cox.net> wrote in message
news:e%23TaqM2eGHA.3572@TK2MSFTNGP04.phx.gbl...
> Don't bother! Debug mode is very different. It adds code to keep objects
> around. Do you really want your unreferenced objects to disappear while
> you're trying to look at them in debug mode? Debug mode would be
> impossible if your objects were being collected. In general, GC in debug
> mode follows scope rules.
>
> You can't do any memory testing with debug builds!
>
> --
> Phil Wilson
> [Microsoft MVP-Windows Installer]
>
> "Mike King" <emailMK@excite.com> wrote in message
> news:uWEAUj0eGHA.3468@TK2MSFTNGP03.phx.gbl...
>> "Tasos Vogiatzoglou" <tvoglou@gmail.com> wrote in message
>> news:1148045066.219380.186420@i39g2000cwa.googlegroups.com...
>>>I think that the debugger causes this.
>>>
>>> I can see the difference :)
>>>
>>
>> Thanks! I'm going to start a new thread over in
>> microsoft.public.vsnet.debugging.
>>
>
>