1

I am testing the memory usage of EF5 vs. EF6.1 (code first, POCO, ProxyCreation enabled) and came across some concerning behavior.

My test is simple:

1) Check memory using GC.GetTotalMemory(false)

2) Run ~20 complex queries through different DataContexts, keep references to all results throughout

3) Compare memory using GS.GetTotalMemory(false)

4) Clear references to everything

5) Compare memory ssing GC.GetTotalMemory(true) (forces garbage collection

Comparing the memory from (3) to (5) gives me an idea of how much memory has been allocated by EF in the process.

There was little difference between EF5 and EF6.1

However there is a substantial difference between compiling in Debug mode vs Release mode:

  • Debug mode: ~150MB allocated

  • Release mode: ~280MB allocated

I have verified these results as follows:

  • Comparable results appear in Task Manager (private working set)

  • Same for EF5 and EF6.1

  • Same for running within Visual Studio and running EXE directly

  • On a workstation with no other programs running

  • There are no [if #debug] statements within my code

What could possibly be the cause, and how could I investigate further?

Brendan Hill
  • 3,406
  • 4
  • 32
  • 61
  • Hi @Brendan, You may want to remove b) from this question. You're more likely to get answers when you ask only a single question, not to mention the fact that you've already asked the debug question separately. – Simon MᶜKenzie Jun 12 '14 at 05:53
  • Thanks. I only decided to post (b) later on so I've removed it from this question. – Brendan Hill Jun 12 '14 at 06:07

1 Answers1

0

After further investigation I found the issue was a bit more general.

DEBUG mode was configured to compile for x86, while Release was Any CPU (so x64).

Presumably EF is very pointer-heavy hence the extra memory usage in x64.

There seems to be more information here:

Performance difference using entity framework in 32 bit and 64 bit

Community
  • 1
  • 1
Brendan Hill
  • 3,406
  • 4
  • 32
  • 61