Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit469ec67

Browse files
committed
fixed leak in NewReference.Move
fixes#1872
1 parent59b1c51 commit469ec67

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎src/runtime/Native/NewReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public PyObject MoveToPyObject()
4747
/// </summary>
4848
publicNewReferenceMove()
4949
{
50-
varresult=newNewReference(this);
50+
varresult=DangerousFromPointer(this.DangerousGetAddress());
5151
this.pointer=default;
5252
returnresult;
5353
}

‎tests/test_constructors.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""Test CLR class constructor support."""
44

55
importpytest
6+
importsys
67

78
importSystem
89

@@ -71,6 +72,19 @@ def test_default_constructor_fallback():
7172
ob=DefaultConstructorMatching("2")
7273

7374

75+
deftest_constructor_leak():
76+
fromSystemimportUri
77+
fromPython.RuntimeimportRuntime
78+
79+
uri=Uri("http://www.python.org")
80+
Runtime.TryCollectingGarbage(20)
81+
ref_count=sys.getrefcount(uri)
82+
83+
# check disabled due to GC uncertainty
84+
# assert ref_count == 1
85+
86+
87+
7488
deftest_string_constructor():
7589
fromSystemimportString,Char,Array
7690

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp