Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixed leak in NewReference.Move
fixes #1872
  • Loading branch information
lostmsu committed Jul 14, 2022
commit 469ec671fc9d7ee2f149a6687b5c7aeb5f861563
2 changes: 1 addition & 1 deletion src/runtime/Native/NewReference.cs
Original file line number Diff line number Diff 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
14 changes: 14 additions & 0 deletions tests/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Test CLR class constructor support."""

import pytest
import sys

import System

Expand Down Expand 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