8000 Merge pull request #27 from QuantConnect/fix-memory-leak-add-pyobject… · saaib/pythonnet@161d442 · GitHub
[go: up one dir, main page]

Skip to content 65FE

Commit 161d442

Browse files
authored
Merge pull request QuantConnect#27 from QuantConnect/fix-memory-leak-add-pyobject-finalizer
Fix memory leak add pyobject finalizer
2 parents f116429 + 2c94c90 commit 161d442

23 files changed

+1038
-380
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.0.5.17
2+
current_version = 1.0.5.18
33
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
44
serialize =
55
{major}.{minor}.{patch}.{release}{dev}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1919
- Catches exceptions thrown in C# iterators (yield returns) and rethrows them in python ([#475][i475])([#693][p693])
2020
- Implemented GetDynamicMemberNames() for PyObject to allow dynamic object members to be visible in the debugger ([#443][i443])([#690][p690])
2121
- Incorporated reference-style links to issues and pull requests in the CHANGELOG ([#608][i608])
22+
- Added PyObject finalizer support, Python objects referred by C# can be auto collect now.
2223

2324
### Changed
25+
- PythonException included C# call stack
2426

2527
### Fixed
2628

conda.recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: pythonnet
3-
version: "1.0.5.17"
3+
version: "1.0.5.18"
44

55
build:
66
skip: True # [not win]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def run(self):
485485

486486
setup(
487487
name="pythonnet",
488-
version="1.0.5.17",
488+
version="1.0.5.18",
489489
description=".Net and Mono integration for Python",
490490
url='https://pythonnet.github.io/',
491491
license='MIT',

src/SharedAssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
// Version Information. Keeping it simple. May need to revisit for Nuget
2626
// See: https://codingforsmarties.wordpress.com/2016/01/21/how-to-version-assemblies-destined-for-nuget/
2727
// AssemblyVersion can only be numeric
28-
[assembly: AssemblyVersion("1.0.5.17")]
28+
[assembly: AssemblyVersion("1.0.5.18")]

src/clrmodule/ClrModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void initclr()
5353
{
5454
#if USE_PYTHON_RUNTIME_VERSION
5555
// Has no effect until SNK works. Keep updated anyways.
56-
Version = new Version("1.0.5.17"),
56+
Version = new Version("1.0.5.18"),
5757
#endif
5858
CultureInfo = CultureInfo.InvariantCulture
5959
};
Lines changed: 125 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,126 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3-
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProjectGuid>{4165C59D-2822-499F-A6DB-EACA4C331EB5}</ProjectGuid>
7-
<OutputType>Library</OutputType>
8-
<AssemblyName>Python.EmbeddingTest</AssemblyName>
9-
<RootNamespace>Python.EmbeddingTest</RootNamespace>
10-
<DocumentationFile>bin\Python.EmbeddingTest.xml</DocumentationFile>
11-
<OutputPath>bin\</OutputPath>
12-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13-
<TargetFrameworkProfile />
14-
<NoWarn>1591</NoWarn>
15-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
16-
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
17-
<LangVersion>6</LangVersion>
18-
<RestorePackages>true</RestorePackages>
19-
<ErrorReport>prompt</ErrorReport>
20-
</PropertyGroup>
21-
<PropertyGroup Condition=" '$(Platform)' == 'x86'">
22-
<PlatformTarget>x86</Platform 10000 Target>
23-
</PropertyGroup>
24-
<PropertyGroup Condition=" '$(Platform)' == 'x64'">
25-
<PlatformTarget>x64</PlatformTarget>
26-
</PropertyGroup>
27-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMono'">
28-
<DebugSymbols>true</DebugSymbols>
29-
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
30-
<DebugType>full</DebugType>
31-
</PropertyGroup>
32-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
33-
<DefineConstants Condition="'$(DefineConstants)' == ''">
34-
</DefineConstants>
35-
<Optimize>true</Optimize>
36-
<DebugType>pdbonly</DebugType>
37-
</PropertyGroup>
38-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
39-
<DebugSymbols>true</DebugSymbols>
40-
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
41-
<DebugType>full</DebugType>
42-
</PropertyGroup>
43-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
44-
<DefineConstants Condition="'$(DefineConstants)' == ''">
45-
</DefineConstants>
46-
<Optimize>true</Optimize>
47-
<DebugType>pdbonly</DebugType>
48-
</PropertyGroup>
49-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
50-
<DebugSymbols>true</DebugSymbols>
51-
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
52-
<DebugType>full</DebugType>
53-
</PropertyGroup>
54-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
55-
<DefineConstants Condition="'$(DefineConstants)' == ''">
56-
</DefineConstants>
57-
<Optimize>true</Optimize>
58-
<DebugType>pdbonly</DebugType>
59-
</PropertyGroup>
60-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
61-
<DebugSymbols>true</DebugSymbols>
62-
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
63-
<DebugType>full</DebugType>
64-
</PropertyGroup>
65-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
66-
<DefineConstants Condition="'$(DefineConstants)' == ''">
67-
</DefineConstants>
68-
<Optimize>true</Optimize>
69-
<DebugType>pdbonly</DebugType>
70-
</PropertyGroup>
71-
<ItemGroup>
72-
<Reference Include="Microsoft.CSharp" />
73-
<Reference Include="nunit.framework, Version=3.7.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
74-
<HintPath>..\..\packages\NUnit.3.7.1\lib\net40\nunit.framework.dll</HintPath>
75-
</Reference>
76-
<Reference Include="System" />
77-
</ItemGroup>
78-
<ItemGroup>
79-
<None Include="..\pythonnet.snk" />
80-
<None Include="packages.config" />
81-
</ItemGroup>
82-
<ItemGroup>
83-
<Compile Include="dynamic.cs" />
84-
<Compile Include="pyimport.cs" />
85-
<Compile Include="pyinitialize.cs" />
86-
<Compile Include="pyrunstring.cs" />
87-
<Compile Include="TestConverter.cs" />
88-
<Compile Include="TestCustomMarshal.cs" />
89-
<Compile Include="TestExample.cs" />
90-
<Compile Include="TestPyAnsiString.cs" />
91-
<Compile Include="TestPyFloat.cs" />
92-
<Compile Include="TestPyInt.cs" />
93-
<Compile Include="TestPyList.cs" />
94-
<Compile Include="TestPyLong.cs" />
95-
<Compile Include="TestPyNumber.cs" />
96-
<Compile Include="TestPyObject.cs" />
97-
<Compile Include="TestPySequence.cs" />
98-
<Compile Include="TestPyString.cs" />
99-
<Compile Include="TestPythonException.cs" />
100-
<Compile Include="TestPythonEngineProperties.cs" />
101-
<Compile Include="TestPyTuple.cs" />
102-
<Compile Include="TestNamedArguments.cs" />
103-
<Compile Include="TestPyWith.cs" />
104-
<Compile Include="TestRuntime.cs" />
105-
<Compile Include="TestPyScope.cs" />
106-
</ItemGroup>
107-
<ItemGroup>
108-
<ProjectReference Include="..\runtime\Python.Runtime.csproj">
109-
<Project>{097B4AC0-74E9-4C58-BCF8-C69746EC8271}</Project>
110-
<Name>Python.Runtime</Name>
111-
</ProjectReference>
112-
</ItemGroup>
113-
<ItemGroup>
114-
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
115-
</ItemGroup>
116-
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
117-
<PropertyGroup>
118-
<TargetAssembly>$(TargetPath)</TargetAssembly>
119-
<TargetAssemblyPdb>$(TargetDir)$(TargetName).pdb</TargetAssemblyPdb>
120-
</PropertyGroup>
121-
<Target Name="AfterBuild">
122-
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
123-
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
124-
</Target>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{4165C59D-2822-499F-A6DB-EACA4C331EB5}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AssemblyName>Python.EmbeddingTest</AssemblyName>
9+
<RootNamespace>Python.EmbeddingTest</RootNamespace>
10+
<DocumentationFile>bin\Python.EmbeddingTest.xml</DocumentationFile>
11+
<OutputPath>bin\</OutputPath>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<TargetFrameworkProfile />
14+
<NoWarn>1591</NoWarn>
15+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
16+
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
17+
<LangVersion>6</LangVersion>
18+
<RestorePackages>true</RestorePackages>
19+
<ErrorReport>prompt</ErrorReport>
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Platform)' == 'x86'">
22+
<PlatformTarget>x86</PlatformTarget>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Platform)' == 'x64'">
25+
<PlatformTarget>x64</PlatformTarget>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMono'">
28+
<DebugSymbols>true</DebugSymbols>
29+
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
30+
<DebugType>full</DebugType>
31+
</PropertyGroup>
32+
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
33+
<DefineConstants Condition="'$(DefineConstants)' == ''">
34+
</DefineConstants>
35+
<Optimize>true</Optimize>
36+
<DebugType>pdbonly</DebugType>
37+
</PropertyGroup>
38+
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
39+
<DebugSymbols>true</DebugSymbols>
40+
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
41+
<DebugType>full</DebugType>
42+
</PropertyGroup>
43+
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
44+
<DefineConstants Condition="'$(DefineConstants)' == ''">
45+
</DefineConstants>
46+
<Optimize>true</Optimize>
47+
<DebugType>pdbonly</DebugType>
48+
</PropertyGroup>
49+
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
50+
<DebugSymbols>true</DebugSymbols>
51+
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
52+
<DebugType>full</DebugType>
53+
</PropertyGroup>
54+
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
55+
<DefineConstants Condition="'$(DefineConstants)' == ''">
56+
</DefineConstants>
57+
<Optimize>true</Optimize>
58+
<DebugType>pdbonly</DebugType>
59+
</PropertyGroup>
60+
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
61+
<DebugSymbols>true</DebugSymbols>
62+
<DefineConstants Condition="'$(DefineConstants)' == ''">DEBUG;TRACE</DefineConstants>
63+
<DebugType>full</DebugType>
64+
</PropertyGroup>
65+
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
66+
<DefineConstants Condition="'$(DefineConstants)' == ''">
67+
</DefineConstants>
68+
<Optimize>true</Optimize>
69+
<DebugType>pdbonly</DebugType>
70+
</PropertyGroup>
71+
<ItemGroup>
72+
<Reference Include="Microsoft.CSharp" />
73+
<Reference Include="nunit.framework, Version=3.7.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
74+
<HintPath>..\..\packages\NUnit.3.7.1\lib\net40\nunit.framework.dll</HintPath>
75+
</Reference>
76+
<Reference Include="System" />
77+
</ItemGroup>
78+
<ItemGroup>
79+
<None Include="..\pythonnet.snk" />
80+
<None Include="packages.config" />
81+
</ItemGroup>
82+
<ItemGroup>
83+
<Compile Include="dynamic.cs" />
84+
<Compile Include="pyimport.cs" />
85+
<Compile Include="pyinitialize.cs" />
86+
<Compile Include="pyrunstring.cs" />
87+
<Compile Include="TestConverter.cs" />
88+
<Compile Include="TestCustomMarshal.cs" />
89+
<Compile Include="TestExample.cs" />
90+
<Compile Include="TestFinalizer.cs" />
91+
<Compile Include="TestPyAnsiString.cs" />
92+
<Compile Include="TestPyFloat.cs" />
93+
<Compile Include="TestPyInt.cs" />
94+
<Compile Include="TestPyList.cs" />
95+
<Compile Include="TestPyLong.cs" />
96+
<Compile Include="TestPyNumber.cs" />
97+
<Compile Include="TestPyObject.cs" />
98+
<Compile Include="TestPySequence.cs" />
99+
<Compile Include="TestPyString.cs" />
100+
<Compile Include="TestPythonException.cs" />
101+
<Compile Include="TestPythonEngineProperties.cs" />
102+
<Compile Include="TestPyTuple.cs" />
103+
<Compile Include="TestNamedArguments.cs" />
104+
<Compile Include="TestPyWith.cs" />
105+
<Compile Include="TestRuntime.cs" />
106+
<Compile Include="TestPyScope.cs" />
107+
</ItemGroup>
108+
<ItemGroup>
109+
<ProjectReference Include="..\runtime\Python.Runtime.csproj">
110+
<Project>{097B4AC0-74E9-4C58-BCF8-C69746EC8271}</Project>
111+
<Name>Python.Runtime</Name>
112+
</ProjectReference>
113+
</ItemGroup>
114+
<ItemGroup>
115+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
116+
</ItemGroup>
117+
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
118+
<PropertyGroup>
119+
<TargetAssembly>$(TargetPath)</TargetAssembly>
120+
<TargetAssemblyPdb>$(TargetDir)$(TargetName).pdb</TargetAssemblyPdb>
121+
</PropertyGroup>
122+
<Target Name="AfterBuild">
123+
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
124+
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
125+
</Target>
125126
</Project>

0 commit comments

Comments
 (0)
0