Last post Sep 06, 2014 11:39 AM by v2kea60
Sep 05, 2014 04:00 AM|stevew1975|LINK
Using the Ants memory profiler we have discovered that when using the Entity Framework, the system seems to grab about 100mb of unused memory. It is saying that it is fragmented. The only code that we have run from a test project is below.
I have tried with a smaller model, and it is still using some unused memory. My one theory is that Ants is profiling this incorrectly and the system is actually using the memory. Any ideas would be appreciated.
Thanks very much
using (DPMODEL.DPEntities ent = new DPMODEL.DPEntities())
ent.Database.Connection.ConnectionString = "connectionstring";
var c1 = from c in ent.debugs.AsNoTracking() select c;
List<DPModel.debug> lst = c1.ToList();
Sep 05, 2014 10:20 AM|_Manvel_|LINK
I don't believe ANTS results is incorrect. Fragmentation is a real issue within memory management in .NET 4.0 for
Large Object Heap (LOH). Since LOH doesn't have compaction, it is possible to run into fragmentation issue. This
was changed in .NET 4.5.
I would investigate this further using
WinDbg. Dump the heap, check what objects do you have in the heap. What's their size (Objects equal or bigger than 85kb will live in LOH). Check the Free memory you have in LOH.
If results do not make sense, come back here, post the results what you have, and people might be able to help you out.
Sep 05, 2014 02:20 PM|stevew1975|LINK
Thanks for your reply. I quickly tried the new .net 4.5.1 compact once feature yesterday, but it did not seem to do anything. Maybe I did not look into it enough. I will try again on Monday.
It is strange that it happens so consistantly with the Entity Framework. I just have a small project using our model, and as soon as it runs a query the memory is showing as fragmented (taking over 100mb and showing it as unused). I would have thought
lots of other people would have seen similar issues.
Sep 06, 2014 11:39 AM|v2kea60|LINK
Manvel's advice is perfect! There's nothing in the query that is inherently wrong. However, there's been a lot of work on EF versions.
MSFT was aware of certain types of queries causing issues, there a page out there from MSFT comparing EF query types to response times and I believe it had memory concerns as well.