-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: discussions #248 memory leak #252
Conversation
- added a cache for dynamic libraries to eliminate the constant loading of new ones into the AppDomain (memory leak) - add test for this case
PR Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @KaJIbI4, great catch and nice improvement! 👏
Before merging, I'd love to hear your thoughts on cache management. Since it's a static class, the cache object never gets cleared. Do you think that's fine as-is, or would it be better to provide a way for users to dispose of it when needed?
I was thinking maybe we should consider implementing one of these suggestions.
|
In the case of classical caching, this would be an absolutely correct remark. In my opinion, in this particular case, there is not much point in forcibly cleaning anything, because the dictionary will contain only the main types used in filtering entities, and there are not many such types. |
@KaJIbI4 I have no words to thank you for your fix, I was about to give up on my memory leak after spending days trying to figure it out - now the leak is gone like magic. Thanks a million! |
Description
Added a cache for dynamic libraries to eliminate the constant loading of new ones into the AppDomain, fix memory leak #248 and increase the speed of operation in entity framework compatibility mode.
When the
EntityFrameworkCompatibilityLayer = true
and filters are used, new assemblies are created on each request and loaded into the currentAppDomain
. There is no unloading of these assemblies from the domain, and the unmanaged memory grows over time. When creating a dynamic assembly, you can useAssemblyBuilderAccess.RunAndCollect
and then.net
sort of cleans up the memory, but there are still overhead costs for constant creation and loading into the domain. Therefore, it was decided to add a cache. In addition, the cache would speed up (if there was a flag) the old version of the work.QueryBuilderBuildBenchmark:
EntityFrameworkCompatibilityLayer = false
, part of the code is not usedEntityFrameworkCompatibilityLayer = true
, no cacheEntityFrameworkCompatibilityLayer = true
, with cacheType of change
Checklist