Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5f1c48

Browse files
committed
removed DisposePythonWrappersForClrTypes
they are no longer needed as ClassBase instances no longer hold Python references to themselves
1 parent cbe1dd2 commit d5f1c48

2 files changed

Lines changed: 3 additions & 23 deletions

File tree

src/runtime/classmanager.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,8 @@ public static void Reset()
5454
cache.Clear();
5555
}
5656

57-
internal static void DisposePythonWrappersForClrTypes()
57+
internal static void RemoveClasses()
5858
{
59-
var visited = new HashSet<IntPtr>();
60-
var visitedHandle = GCHandle.Alloc(visited);
61-
var visitedPtr = (IntPtr)visitedHandle;
62-
try
63-
{
64-
foreach (var cls in cache.Values)
65-
{
66-
// XXX: Force to release instance's managed resources
67-
// but not dealloc itself immediately.
68-
// These managed resources should preserve vacant shells
69-
// since others may still referencing it.
70-
BorrowedReference meta = Runtime.PyObject_TYPE(cls);
71-
ManagedType.CallTypeTraverse(cls, meta, TraverseTypeClear, visitedPtr);
72-
ManagedType.CallTypeClear(cls, meta);
73-
}
74-
}
75-
finally
76-
{
77-
visitedHandle.Free();
78-
}
7959
cache.Clear();
8060
}
8161

src/runtime/runtime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ internal static void Shutdown(ShutdownMode mode)
284284
RemoveClrRootModule();
285285

286286
MoveClrInstancesOnwershipToPython();
287-
ClassManager.DisposePythonWrappersForClrTypes();
287+
ClassManager.RemoveClasses();
288288
TypeManager.RemoveTypes();
289289

290290
Finalizer.Shutdown();
@@ -486,7 +486,7 @@ private static void MoveClrInstancesOnwershipToPython()
486486
handle?.Free();
487487
if (handle is not null)
488488
{
489-
ManagedType.SetGCHandle(@ref, default);
489+
ManagedType.SetGCHandle(@ref, default);
490490
}
491491
}
492492

0 commit comments

Comments
 (0)