Closed
Description
Environment
- Pythonnet version: 2.3.0
- Python version: 3.6-32
- Operating System: Windows 10
Details
- Getting a
MethodBinding
for a generic method results in the reference count being too high, so thetp_dealloc
method on theMethodBinding
never gets called, even when theMethodBinding
goes out of scope.
namespace PlainOldNamespace
{
public class PlainOldClass
{
public void NonGenericMethod() { }
public void GenericMethod<T>() { }
}
}
import clr, sys
clr.AddReference("PlainOldAssembly")
from PlainOldNamespace import PlainOldClass
poc = PlainOldClass()
sys.getrefcount(poc.NonGenericMethod)
# 1
sys.getrefcount(poc.GenericMethod[clr.System.Double])
# 2 - should be 1
I think this could be down to a bug in MethodBinding.cs. This line looks suspicious. Why should the reference count get incremented here?
https://github.com/pythonnet/pythonnet/blob/master/src/runtime/methodbinding.cs#L59
Metadata
Metadata
Assignees
Labels
No labels