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

Fixed a leak inNewReference.Move#1873

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
filmor merged 2 commits intopythonnet:releasefromlosttech:bugs/ctor-leak
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionssrc/runtime/Finalizer.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,6 +106,7 @@ internal IncorrectRefCountException(IntPtr ptr)

#endregion

[ForbidPythonThreads]
public void Collect() => this.DisposeAll();

internal void ThrottledCollect()
Expand Down
2 changes: 1 addition & 1 deletionsrc/runtime/Native/NewReference.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,7 +47,7 @@ public PyObject MoveToPyObject()
/// </summary>
public NewReference Move()
{
var result =new NewReference(this);
var result =DangerousFromPointer(this.DangerousGetAddress());
this.pointer = default;
return result;
}
Expand Down
1 change: 1 addition & 0 deletionssrc/runtime/Runtime.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -359,6 +359,7 @@ static bool TryCollectingGarbage(int runs, bool forceBreakLoops)
/// </summary>
/// <param name="runs">Total number of GC loops to run</param>
/// <returns><c>true</c> if a steady state was reached upon the requested number of tries (e.g. on the last try no objects were collected).</returns>
[ForbidPythonThreads]
public static bool TryCollectingGarbage(int runs)
=> TryCollectingGarbage(runs, forceBreakLoops: false);

Expand Down
14 changes: 14 additions & 0 deletionstests/test_constructors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
"""Test CLR class constructor support."""

import pytest
import sys

import System

Expand DownExpand Up@@ -71,6 +72,19 @@ def test_default_constructor_fallback():
ob = DefaultConstructorMatching("2")


def test_constructor_leak():
from System import Uri
from Python.Runtime import Runtime

uri = Uri("http://www.python.org")
Runtime.TryCollectingGarbage(20)
ref_count = sys.getrefcount(uri)

# check disabled due to GC uncertainty
# assert ref_count == 1



def test_string_constructor():
from System import String, Char, Array

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp