![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I tried your example and it is collected (I tried it in a winform). |
#4
| |||
| |||
|
|
Can someone please explain why the DataSet isn't being collected? If I un-comment "dr = null", then the memory is freed. using System; using System.Data; class Class1 { [STAThread] static void Main(string[] args) { DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("Customers"); dt.Columns.Add("custid", typeof(int)); for (int i=0; i<100000; ++i) { DataRow dr = dt.NewRow(); dt.Rows.Add(dr); //dr = null; } Console.WriteLine(System.GC.GetTotalMemory(true)); dt = null; ds = null; System.GC.Collect(); Console.WriteLine(System.GC.GetTotalMemory(true)); } } |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
I think that the debugger causes this. I can see the difference ![]() |
#7
| |||
| |||
|
|
"Tasos Vogiatzoglou" <tvoglou (AT) gmail (DOT) com> wrote in message news:1148045066.219380.186420 (AT) i39g2000cwa (DOT) 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. |
#8
| |||
| |||
|
|
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 (AT) excite (DOT) com> wrote in message news:uWEAUj0eGHA.3468 (AT) TK2MSFTNGP03 (DOT) phx.gbl... "Tasos Vogiatzoglou" <tvoglou (AT) gmail (DOT) com> wrote in message news:1148045066.219380.186420 (AT) i39g2000cwa (DOT) 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. |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
The GC process is a background process that runs on a different thread than your application. Calling the GC to collect doesn't activate it explicitly. Meaning you can't know when the GC will collect. You only know that it will happen. Multi threading kind of shit. |
|
You should place an event handler to see when it does take place. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |