Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework consuming a lot of memory (possible memory leak?)
    primarykey
    data
    text
    <p>We are using EF4.3.1 in a WCF service ( our business \ application layer). We are using EF Code First with existing database and Fluent Mapping (EntityTypeConfiguraiton). An instance of DbContext is created for each request and then disposed off. </p> <p>We have a generic repository which uses the DbContext. </p> <p>When running on test servers we found that the Business layer app pool is going out of memory in 30 mins or so with 10 concurrent users. We took dump of the IIS worker process and found that EF is consuming a lot of memory, there were many object in on large object heap created by EF. We could see objects for data retrieved from th DB on the heap. Not sure if the DbContext dispose is taking care of this. The % time in GC was very high (> 16%). One strange thing we noticed in the dump file was, there was a huge string object (around 87MB) storing string representation of all my mapping files. I found this to be very strange,</p> <p>Has anybody encountered any such memory leak issue with EF? Also please also let us know if there is something wrong in our usage of EF. Please let me know if more details are required.</p> <p>Thanks Prasad</p> <p><strong>EDIT</strong> We inject an instance of DbContext using AutiFac DI (WCF integration). The life time for Dbcontext is InstancePerLifeTime ( one request per http request). We have implemented this way to share the instance of DbContext in all repositories instances in one HTTPrequest.</p> <p>The way we access database is // declaration IGenericRepository UserRepository {get;set;} // Property injection using AutoFac</p> <p>// Usage var user = UserRepository.FindBy(u => u.userid == "test@test.com");</p> <p>We are not using explicit transactions in repositories. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload