8000 Wait for full GC Complete · pythonnet/pythonnet@0b9d2c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b9d2c1

Browse files
committed
Wait for full GC Complete
1 parent 97e61a5 commit 0b9d2c1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/embed_tests/TestFinalizer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ public void TearDown()
2828
private static void FullGCCollect()
2929
{
3030
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
31+
try
32+
{
33+
GC.WaitForFullGCComplete();
34+
}
35+
catch (NotImplementedException)
36+
{
37+
// Some clr runtime didn't implement GC.WaitForFullGCComplete yet.
38+
}
3139
GC.WaitForPendingFinalizers();
3240
}
3341

src/runtime/runtime.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,13 @@ internal static void Shutdown(ShutdownMode mode)
391391
GC.Collect();
392392
try
393393
{
394-
GC.WaitForPendingFinalizers();
394+
GC.WaitForFullGCComplete();
395395
}
396396
catch (NotImplementedException)
397397
{
398398
// Some clr runtime didn't implement GC.WaitForFullGCComplete yet.
399399
}
400+
GC.WaitForPendingFinalizers();
400401
PyGILState_Release(state);
401402
// Then release the GIL for good, if there is somehting to release
402403
// Use the unchecked version as the checked version calls `abort()`

0 commit comments

Comments
 (0)
0