2

I am running into some problems where huge objects occupy memory and the reference is not being released. I used .Net Memory Profiler to find out the root object and it references to Entity Framework class.

Is there a way i can disable the caching of queried objects in Entity framework without chanign the code? Something in the config file may be?

1

1 Answer 1

3

You should have using statements to help dispose you ObjectContext. EF keeps an object graph of the queried objects. I think you could use objectContext.Detach(Entity); to detach your entities from the ObjectContext.

Sign up to request clarification or add additional context in comments.

4 Comments

+1: The Entity Framework contexts are IDisposable, and you should expect that they will consume a lot of resources if they are not disposed of quickly.
what if i say my EF object context is in a Static class? Does this raise the red flag?
I would think so, because every object you load will stay loaded for the life of the application. IMO Your context should be created, as little data pulled into it as needed, and then thrown away when finished.
@Asdfg, Yes a big red flag. Please see the following links for more detailed exp. stackoverflow.com/questions/1990876/… , stackoverflow.com/questions/1785119/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.