-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Using IQueryable.Contains() in an expression causes a memory leak #11015
Comments
Related #9301 |
@jessebarocio - We get separate cache entry for each query since, EnumerableQueries are opaque to us. We would not know genders would enumerate too. Hence they don't match existing cache entry. If you move genders declaration outside then we do reference equality on value causing cached entry to be used. If we parametrize the Queryable then we can use same query cache while still enumerating to different SQL. Current pipeline already supports that with Contains. We will be doing that as a part of fixing this issue. |
Issue: Non-EF IQueryables are opaque to us so we cannot compare them causing new cache entry for each of them. But we have mechanism for running a query with parameter of type enumerable using 2nd level cache. In this case, we can just parametrize non-EF IQueryable to cause a parameter which gets inlined for Contains in Sql Resolves #11015
Issue: Non-EF IQueryables are opaque to us so we cannot compare them causing new cache entry for each of them. But we have mechanism for running a query with parameter of type enumerable using 2nd level cache. In this case, we can just parametrize non-EF IQueryable to cause a parameter which gets inlined for Contains in Sql Resolves #11015
Issue: Non-EF IQueryables are opaque to us so we cannot compare them causing new cache entry for each of them. But we have mechanism for running a query with parameter of type enumerable using 2nd level cache. In this case, we can just parametrize non-EF IQueryable to cause a parameter which gets inlined for Contains in Sql Resolves #11015
If you use
IQueryable<T>.Contains()
in an expression it will cause a memory leak. The leak appears to be in theCompiledQueryCache
as memory snapshots show aMemoryCache
growing like crazy.The obvious workaround is to not use an IQueryable in the expression. I never intended to and I've already fixed it. But it was difficult to track down the leak so I still think it should be fixed if possible.
Steps to reproduce
Here's a complete sample to reproduce the issue.
Further technical details
EF Core version: 2.0.1
Database Provider: Tested with SqlServer & Sqlite providers
Operating system: Windows 10
IDE: Visual Studio 2017 15.5.2
The text was updated successfully, but these errors were encountered: