-
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
Guide on memory leak warning ef core 3.0 preview9 #17623
Comments
ToGuid method which is being used in projection is defined on Repository so expression tree contains reference to object of your repository. Since your repository has DbContext also inside a field, it is actually leaking memory. Easy way to fix this is to use static method so you are not putting your repository objects inside expression tree. |
@smitpatel Thank you so much I was looking at the Map() method not realising the ToGuid() was probably the problem. Making it static worked :) |
@smitpatel looks like the error happens in the Microsoft.AspNetCore.DataProtection.EntityFrameworkCore Package of AspNetCore: (Version:
|
@schmitch - I filed issue dotnet/aspnetcore#13696 on aspnetcore repo. Thanks for pointing us to the error. |
@smitpatel is it possible to improve the message: Client projection contains reference to constant expression of type: KalikoCMS.Legacy.Data.Repositories.LegacyContentTypeRepository. Client projection contains reference to constant expression ToGuid of type: KalikoCMS.Legacy.Data.Repositories.LegacyContentTypeRepository. to better point to the expression that is causing the issue |
@JanEggers - In expression tree we-encounter the constant, but it may not always possible to understand why the constant there. I will look into it, and try to improve exception message to be as useful as it can be. |
Improve the exception message and add a fwlink. |
@divega - To generate fwlink. |
@smitpatel link is https://go.microsoft.com/fwlink/?linkid=2103067, for now pointing to query overview. Do we need a docs issue to add the contents? I am thinking we need to go back and review all the fwlinks created for this release in search for gaps. |
OK- I have come across this with code like this:
` I don't see what is wrong with the above code and why the warning exception is thrown. |
* Update dependencies from https://github.com/aspnet/Extensions build 20190926.1 - Microsoft.Extensions.Configuration.Json - 3.1.0-preview1.19476.1 - Microsoft.Extensions.DependencyInjection - 3.1.0-preview1.19476.1 - Microsoft.Extensions.Configuration.EnvironmentVariables - 3.1.0-preview1.19476.1 - Microsoft.Extensions.Configuration - 3.1.0-preview1.19476.1 - Microsoft.Extensions.Caching.Memory - 3.1.0-preview1.19476.1 - Microsoft.Extensions.HostFactoryResolver.Sources - 3.1.0-preview1.19476.1 - Microsoft.Extensions.Logging - 3.1.0-preview1.19476.1 * Improve exception message for memory leak warning Resolves #17623 * Add regression test for issue#14772 Resolves #14772 * Fix to #18002 - Query/Test: convert AssertQuery methods to strongly typed versions (part2) converting AssertQuery(...) (i.e. queryable, non scalar result) to strongly typed versions * Update dependencies from https://github.com/aspnet/Extensions build 20190926.3 - Microsoft.Extensions.Configuration.Json - 3.1.0-preview1.19476.3 - Microsoft.Extensions.DependencyInjection - 3.1.0-preview1.19476.3 - Microsoft.Extensions.Configuration.EnvironmentVariables - 3.1.0-preview1.19476.3 - Microsoft.Extensions.Configuration - 3.1.0-preview1.19476.3 - Microsoft.Extensions.Caching.Memory - 3.1.0-preview1.19476.3 - Microsoft.Extensions.HostFactoryResolver.Sources - 3.1.0-preview1.19476.3 - Microsoft.Extensions.Logging - 3.1.0-preview1.19476.3 Dependency coherency updates - Microsoft.CSharp - 4.7.0-preview1.19470.8 (parent: Microsoft.NETCore.App.Runtime.win-x64) - Microsoft.NETCore.App.Runtime.win-x64 - 3.1.0-preview1.19475.6 (parent: Microsoft.Extensions.Logging) - Microsoft.DotNet.PlatformAbstractions - 3.1.0-preview1.19475.6 (parent: Microsoft.Extensions.Logging) - Microsoft.Extensions.DependencyModel - 3.1.0-preview1.19475.6 (parent: Microsoft.Extensions.Logging) - Microsoft.NETCore.App.Ref - 3.1.0-preview1.19475.6 (parent: Microsoft.Extensions.Logging) - NETStandard.Library.Ref - 2.1.0-preview1.19475.6 (parent: Microsoft.Extensions.Logging) - System.Collections.Immutable - 1.7.0-preview1.19470.8 (parent: Microsoft.NETCore.App.Runtime.win-x64) - System.ComponentModel.Annotations - 4.7.0-preview1.19470.8 (parent: Microsoft.NETCore.App.Runtime.win-x64) - System.Diagnostics.DiagnosticSource - 4.7.0-preview1.19470.8 (parent: Microsoft.NETCore.App.Runtime.win-x64) * Clean Cosmos collections instead of deleting them Reuse Cosmos databases instead of recreating them Don't uniquify database names when using the emulator Use a separate account for PRs Fixes #17925
@MCFHTAGENTS - Please file a new issue and share full repro code. It would be hard to guess what the expression tree would be based on info you posted above. |
Currently using the following project:
https://github.com/KalikoCMS/KalikoCMS.NextGen/blob/netcore3.0-experimental/KalikoCMS.Legacy/Data/Repositories/LegacyRepositoryBase.cs
Using ef core 3.0 preview8 the following code would work:
But in ef core 3.0 preview9 the following error occurs
I understand it could be related to
#13048
#17051
I'm just wondering if there is any guidance on how to solve the issue?
Further technical details
EF Core version: 3.0.0-preview9.19423.6
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system:
IDE: (e.g. Visual Studio 2019 16.3 preview 3.0)
The text was updated successfully, but these errors were encountered: