I have a very simple application using EF. But when it works for a week, memory usage is terrible (80 MB first, 700 MB after one week). When I use dotMemory to profile my application. I find that the memory of the Generation 2 Heap is increasing all the time.

We get a snapshot, and finally find the stored bytes ef dbcontext the most.

I'm so confused. My application is so simple. Code example:
protected CarbonBrushMonitorEntities _entities = new MYEntities(); public void Add(HistoryData data) { _entities.HistoryDatas.Add(data); _entities.SaveChanges(); }
_entities only starts once at the beginning, and then is used all the time.
Often called the Add function, about 3 times / sec
I have been using Google for a long time and try some methods, such as:
_entities.Configuration.ValidateOnSaveEnabled = false; _entities.Configuration.AutoDetectChangesEnabled = false; _entities.Configuration.LazyLoadingEnabled = false;
but they do not work.
c # entity-framework
yubaolee
source share