diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d38e48c..dea181c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.0.8.8 (21 May 2018) + + - [#167](https://github.com/StefH/System.Linq.Dynamic.Core/issues/167) - Issue: Memory leak in `ConstantExpressionHelper.cs` +fix + +Commits: 65a03284a0...65a03284a0 + + # 1.0.8.7 (08 May 2018) - [#156](https://github.com/StefH/System.Linq.Dynamic.Core/pull/156) - Fix parsing config contributed by Jochen Kühner ([jogibear9988](https://github.com/jogibear9988)) diff --git a/ChangeLog.txt b/ChangeLog.txt index ac3a8c49..8a4944c2 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,5 @@ https://github.com/GitTools/GitReleaseNotes -GitReleaseNotes.exe . /OutputFile CHANGELOG.md /Version 1.0.8.7 +GitReleaseNotes.exe . /OutputFile CHANGELOG.md /Version 1.0.8.8 GitReleaseNotes.exe . /OutputFile CHANGELOG.md /allTags diff --git a/System.Linq.Dynamic.Core.sln b/System.Linq.Dynamic.Core.sln index 358f876f..87a54a0e 100644 --- a/System.Linq.Dynamic.Core.sln +++ b/System.Linq.Dynamic.Core.sln @@ -51,6 +51,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp_net452_EF6", "sr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp_netcore2.0_EF2.0.2_InMemory", "src-console\ConsoleAppEF2.0.2_InMemory\ConsoleApp_netcore2.0_EF2.0.2_InMemory.csproj", "{437473EE-7FBB-4C28-96EC-41E1AEE161F3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemoryLeakTest167", "src-console\MemoryLeakTest167\MemoryLeakTest167.csproj", "{AD4F83E5-4240-485D-BB5C-F43974F716E4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -269,6 +271,22 @@ Global {437473EE-7FBB-4C28-96EC-41E1AEE161F3}.Release|x64.Build.0 = Release|Any CPU {437473EE-7FBB-4C28-96EC-41E1AEE161F3}.Release|x86.ActiveCfg = Release|Any CPU {437473EE-7FBB-4C28-96EC-41E1AEE161F3}.Release|x86.Build.0 = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|ARM.ActiveCfg = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|ARM.Build.0 = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|x64.ActiveCfg = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|x64.Build.0 = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|x86.ActiveCfg = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Debug|x86.Build.0 = Debug|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|Any CPU.Build.0 = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|ARM.ActiveCfg = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|ARM.Build.0 = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|x64.ActiveCfg = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|x64.Build.0 = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|x86.ActiveCfg = Release|Any CPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -287,6 +305,7 @@ Global {E587974C-19A9-426A-A952-216D5F883EB6} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62} {5DC68E83-ABE0-4887-B17E-1ED4EEE89C2C} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62} {437473EE-7FBB-4C28-96EC-41E1AEE161F3} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62} + {AD4F83E5-4240-485D-BB5C-F43974F716E4} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {94C56722-194E-4B8B-BC23-B3F754E89A20} diff --git a/src-console/MemoryLeakTest167/App.config b/src-console/MemoryLeakTest167/App.config new file mode 100644 index 00000000..88fa4027 --- /dev/null +++ b/src-console/MemoryLeakTest167/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src-console/MemoryLeakTest167/MemoryLeakTest167.csproj b/src-console/MemoryLeakTest167/MemoryLeakTest167.csproj new file mode 100644 index 00000000..9b260873 --- /dev/null +++ b/src-console/MemoryLeakTest167/MemoryLeakTest167.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {AD4F83E5-4240-485D-BB5C-F43974F716E4} + Exe + MemoryLeakTest167 + MemoryLeakTest167 + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {b70cd050-3b9c-406c-85fd-1a26394ec7c8} + System.Linq.Dynamic.Core + + + + \ No newline at end of file diff --git a/src-console/MemoryLeakTest167/Program.cs b/src-console/MemoryLeakTest167/Program.cs new file mode 100644 index 00000000..38a49e5a --- /dev/null +++ b/src-console/MemoryLeakTest167/Program.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq.Dynamic.Core; +using System.Linq.Expressions; +using System.Threading; + +namespace MemoryLeakTest167 +{ + class Program + { + static void Main(string[] asArgs) + { + RunThreads(8, RawMemoryLeak); + } + + private static void RunThreads(int nThreads, Action actThreadStart) + { + for (int i = 0; i < nThreads; i++) + { + Thread thread = new Thread(new ThreadStart(actThreadStart)); + thread.Start(); + } + + while (true) + { + Thread.Sleep(5000); + } + } + + private static void RawMemoryLeak() + { + while (true) + { + string sExpr = "1234567890"; + LambdaExpression expr = DynamicExpressionParser.ParseLambda(new ParameterExpression[0], typeof(double), sExpr); + } + } + } +} diff --git a/src-console/MemoryLeakTest167/Properties/AssemblyInfo.cs b/src-console/MemoryLeakTest167/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..6136ad22 --- /dev/null +++ b/src-console/MemoryLeakTest167/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MemoryLeakTest167")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MemoryLeakTest167")] +[assembly: AssemblyCopyright("Copyright © Stef Heyenrath 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ad4f83e5-4240-485d-bb5c-f43974f716e4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/EntityFramework.DynamicLinq/EntityFramework.DynamicLinq.csproj b/src/EntityFramework.DynamicLinq/EntityFramework.DynamicLinq.csproj index cbb3ea0e..0fea0e96 100644 --- a/src/EntityFramework.DynamicLinq/EntityFramework.DynamicLinq.csproj +++ b/src/EntityFramework.DynamicLinq/EntityFramework.DynamicLinq.csproj @@ -2,7 +2,7 @@ Dynamic Linq extensions for EntityFramework which adds Async support EntityFramework.DynamicLinq - 1.0.8.7 + 1.0.8.8 Stef Heyenrath net45;net46 EF diff --git a/src/Microsoft.EntityFrameworkCore.DynamicLinq/Microsoft.EntityFrameworkCore.DynamicLinq.csproj b/src/Microsoft.EntityFrameworkCore.DynamicLinq/Microsoft.EntityFrameworkCore.DynamicLinq.csproj index 237e2186..13d7769c 100644 --- a/src/Microsoft.EntityFrameworkCore.DynamicLinq/Microsoft.EntityFrameworkCore.DynamicLinq.csproj +++ b/src/Microsoft.EntityFrameworkCore.DynamicLinq/Microsoft.EntityFrameworkCore.DynamicLinq.csproj @@ -2,7 +2,7 @@ Dynamic Linq extensions for Microsoft.EntityFrameworkCore which adds Async support Microsoft.EntityFrameworkCore.DynamicLinq - 1.0.8.7 + 1.0.8.8 Stef Heyenrath net451;net46;netstandard1.3;netstandard2.0;uap10.0 $(DefineConstants);EFCORE diff --git a/src/System.Linq.Dynamic.Core/Parser/ConstantExpressionHelper.cs b/src/System.Linq.Dynamic.Core/Parser/ConstantExpressionHelper.cs index 92a00c10..3c0efe7f 100644 --- a/src/System.Linq.Dynamic.Core/Parser/ConstantExpressionHelper.cs +++ b/src/System.Linq.Dynamic.Core/Parser/ConstantExpressionHelper.cs @@ -1,24 +1,29 @@ using System.Collections.Concurrent; -using System.Collections.Generic; using System.Linq.Expressions; namespace System.Linq.Dynamic.Core.Parser { internal static class ConstantExpressionHelper { - private static readonly IDictionary Literals = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Expressions = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Literals = new ConcurrentDictionary(); - public static bool TryGetText(Expression expresion, out string text) + public static bool TryGetText(Expression expression, out string text) { - return Literals.TryGetValue(expresion, out text); + return Literals.TryGetValue(expression, out text); } public static Expression CreateLiteral(object value, string text) { - ConstantExpression expresion = Expression.Constant(value); + if (!Expressions.ContainsKey(value)) + { + ConstantExpression constantExpression = Expression.Constant(value); - Literals.Add(expresion, text); - return expresion; + Expressions.TryAdd(value, constantExpression); + Literals.TryAdd(constantExpression, text); + } + + return Expressions[value]; } } } diff --git a/src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.csproj b/src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.csproj index 3468e6c3..089f2b5d 100644 --- a/src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.csproj +++ b/src/System.Linq.Dynamic.Core/System.Linq.Dynamic.Core.csproj @@ -2,7 +2,7 @@ This is a .NETStandard/ .NET Core port of the the Microsoft assembly for the .Net 4.0 Dynamic language functionality. System.Linq.Dynamic.Core - 1.0.8.7 + 1.0.8.8 Microsoft;Scott Guthrie;King Wilder;Nathan Arnott;Stef Heyenrath net35;net40;net45;net46;uap10.0;netstandard1.3;netstandard2.0 true