3

hoping some of you clever people can help me out here!

We have an ASP.NET web service app, using Entity Framework 1 and EFPocoAdapter. The mem usage of the app pool running this web service keeps growing on every web service call. We currently monitor its mem usage and once it starts to get over 1GB we recycle the app pool to free up the memory.

We instantiate the object context in each web method in a 'using' statement so that doesn't leave open object contexts (observed with efprof).

So I used Ants memory profiler 7 to track whats going on and after the first call to the web service (at this point the EF framework generates its view, etc), I've taken a snapshot. Then make the same call and take another snapshot. Ants shows that the new objects created since the last snapshot are pretty much all related to System.Data.Common.QueryCache.QueryCacheManager.

I know the point of the cache is to improve performance, but in our case I think we need to NOT cache every query plan as the likelihood of repeating those calls is minimal due to the nature of our main app / business.

So, my question..... is there a way of turning off this caching, or am I barking up the wrong tree here and there's something else going on I'm unaware of?

I've searched all over the web for an answer to this, and all I can find is the MergeOption property which seems to be related more to entity tracking for speed / performance improvements.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
John_Higg
  • 31
  • 1
  • You can click on "edited..." and then rollback my formatting changes if you hate it. Unfortunately I don't have another input. Interesting question! Do you know if EF 4 shows the same behaviour? I guess `System.Data.Common.QueryCache` is some low level ADO.NET namespace used by EF but not specific to EF, right? – Slauma Oct 13 '11 at 22:47
  • Thanks for the formatting, it does help! Haven't actually tried using EF4 yet but I believe the query caching is a feature of EF in all versions. – John_Higg Oct 14 '11 at 08:20

1 Answers1

0

If you don't modify the data just select it, you can simply turn off object modification tracking:

datacontext.ObjectTrackingEnabled = false;

It worked for me in a similar situation with Linq2SQL.

balint
  • 3,391
  • 7
  • 41
  • 50