0

Memory usage for a 2 millions dummy rows DataTable using .NET Core 2.0 is 694 MB but using .NET Framework it is 405 MB

Why this discrepancy ?

This is the same sample code used in a console application for both platforms:

DataTable dt = new DataTable();
dt.Columns.Add("a");
dt.Columns.Add("b");
dt.Columns.Add("c");

var watch = Stopwatch.StartNew();

for (int i = 0; i < 2000000; i++)
{
    var row = dt.NewRow();
    row["a"] = i;
    row["b"] = i;
    row["c"] = i;
    dt.Rows.Add(row);
}
watch.Stop();

Console.WriteLine("Time:" + watch.ElapsedMilliseconds.ToString());
Console.WriteLine("Memory (MB):" + GC.GetTotalMemory(false) / 1048576);
Console.WriteLine("Working set (MB):" + Process.GetCurrentProcess().WorkingSet64 / 1048576);
  • 3
    Possibly one is running as a 32 bit app while the other is running as a 64 bit app? Try printing out a message saying which it is before you start timing, see [How do I tell if my application is running as a 32-bit or 64-bit application?](https://stackoverflow.com/q/266082). – dbc Oct 14 '17 at 19:38
  • 2
    @dbc you are right "Prefer 32-bit" was checked by default for the Full Framework Version – softawareblog.com Oct 14 '17 at 20:35
  • Glad to help. So, add an answer, or close as "a problem that can no longer be reproduced or a simple typographical error"? – dbc Oct 14 '17 at 22:50

1 Answers1

0

"Prefer 32-bit" was checked by default for the Full Framework Version