EntityFramework.DynamicFilters icon indicating copy to clipboard operation
EntityFramework.DynamicFilters copied to clipboard

EntityFramework.DynamicFilters have Memory Leakage

Open yadav-dhananjay opened this issue 8 years ago • 3 comments

I am using EntityFramework.DynamicFilters in my application. I observed my application throw memory exception after 4 to 5 days.

DynamicParamFilter hold memory in Gen2 and keeps on adding more Objects in Gen2, and application crashes when there is no further space for .NET.

memory_graph2_dbcontext

yadav-dhananjay avatar Aug 01 '17 20:08 yadav-dhananjay

That ConcurrentDictionary you are showing is used to cache parameter values that are scoped to specific DbContext instances. That is why DbContext is used as the key. When that is done, an event is registered on the OnDisposing() method of the DbContext to clean it up. I just verified that this is still working in my unit tests.

So can you verify that you are disposing your DbContext instances when you are finished with them?

You can also download the source, reference that instead of the NuGet package, and then stick a break point in the DynamicFilterExtensions.ClearScopedParameters() method. That should get hit when you call Dispose on your DbContext instance. Verify that happens when you manually call Dispose to see that it work. Then see if it's getting hit during your normal application execution. If it gets hit when you force a Dispose but not during normal execution, then your DbContext instances are not being disposed of properly.

jcachat avatar Aug 04 '17 00:08 jcachat

@jcachat I am facing the same issue.

My setup: DBContext that inherits EntityFramework DataContext

i use Using() statements everywhere, so could it still be a Disposing issue?

hhamzah99 avatar Mar 01 '22 14:03 hhamzah99

@yadav-dhananjay do you have any info on how you fixed this?

hhamzah99 avatar Mar 02 '22 07:03 hhamzah99