Here is a image from the ANTS memory profiler. It seens that there are a lot of objects hold in memory. How can I find what I am doing wrong?
I have a hunch you don't dispose the context.
I suggest disposing the context whenever you done interacting with database.
Use using
statement whenever you create the context.
[Edit]
As far as I can see, you cache and don't dispose your EFUnitOfWork
object. It is disposable, which is correct, but I don't see when disposable is called. Seems like you hold a reference to the context for all application run time.
Moreover, you create and hold one context per thread, which will make it even worse.
I can't tell you for sure where you should put Dispose
or using
, as I don't know the usages.
You could put it probably to your Commit
method, but I don't know if the Commit
called only once during database interaction session.
Also, your design might be overcomplicated.
If I were you, I would:
If I had time I would do long-term solution right away.
But again, I can't tell if the complexity of your design is justified, as I don't know how big your application is and what it does and what the requirements are.