I have a project using Microsoft.SqlServer.Types that leaks memory and slows down when retargeting from net472 to netcoreapp3.1.
I'm aware that netcoreapp3.1 don't necessarily can run netfx dlls, but I tried just to see if it would work.
I'm observing two things:
ShortestLineTo
seems to get slower and slower as the programs runs for longer time.
internal static class Program
{
private static void Main()
{
var point = SqlGeography.Point(0, 0);
var sw = Stopwatch.StartNew();
while (true)
{
for (int i = 0; i < 100_000; i++)
{
point.ShortestLineTo(point);
}
Console.WriteLine(sw.ElapsedMilliseconds);
sw.Restart();
}
}
}
https://github.com/dotnet/runtime/issues/353 mentions a memory leak for Marshal.GetFunctionPointerForDelegate
but I'm unsure whether this is the same case.
Running Concurrency Visualizer gave this significant trace.
I've created a smaller example that extracts the relevant parts from the nupkg and calls the unmanaged dll. https://gofile.io/?c=hfAKwe
Edit 2020-03-20:
Tried running the same program with the newly release .Net 5.0 preview1 and now both memory and cpu usage has stabilized.
该修复程序已向后移植到 .net core 3.1.8 https://github.com/dotnet/coreclr/pull/28074
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.