Memory usage in EF 1 web service application keeps growing on each call - query cache issues?

277 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.