Skip to content
Merged
Changes from all 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
added a test for finalization on shutdown
potential issue reported here: 610d309#commitcomment-41601957
  • Loading branch information
lostmsu committed Sep 20, 2020
commit 86a97fd9d5080f9d2e663d366ac7732126bdccb5
12 changes: 12 additions & 0 deletions src/embed_tests/TestFinalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ public void CollectBasicObject()
Assert.GreaterOrEqual(objectCount, 1);
}

[Test]
public void CollectOnShutdown()
{
MakeAGarbage(out var shortWeak, out var longWeak);
FullGCCollect();
var garbage = Finalizer.Instance.GetCollectedObjects();
Assert.IsNotEmpty(garbage);
PythonEngine.Shutdown();
garbage = Finalizer.Instance.GetCollectedObjects();
Assert.IsEmpty(garbage);
}

private static void MakeAGarbage(out WeakReference shortWeak, out WeakReference longWeak)
{
PyLong obj = new PyLong(1024);
Expand Down