X Tutup
Skip to content

Commit 002d730

Browse files
committed
fixed CollectBasicObject by ensuring MakeAGarbage is not keeping temp object alive
1 parent ce76f2e commit 002d730

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/embed_tests/TestFinalizer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using Python.Runtime;
33
using System;
44
using System.Collections.Generic;
5-
using System.ComponentModel;
65
using System.Diagnostics;
76
using System.Linq;
7+
using System.Runtime.CompilerServices;
88
using System.Threading;
99

1010
namespace Python.EmbeddingTest
@@ -47,7 +47,6 @@ private static bool FullGCCollect()
4747
}
4848

4949
[Test]
50-
[Ignore("Ignore temporarily")]
5150
public void CollectBasicObject()
5251
{
5352
Assert.IsTrue(Finalizer.Instance.Enable);
@@ -104,7 +103,6 @@ public void CollectBasicObject()
104103
}
105104

106105
[Test]
107-
[Ignore("Ignore temporarily")]
108106
public void CollectOnShutdown()
109107
{
110108
IntPtr op = MakeAGarbage(out var shortWeak, out var longWeak);
@@ -125,6 +123,7 @@ public void CollectOnShutdown()
125123
Assert.IsEmpty(garbage);
126124
}
127125

126+
[MethodImpl(MethodImplOptions.NoInlining)] // ensure lack of references to obj
128127
private static IntPtr MakeAGarbage(out WeakReference shortWeak, out WeakReference longWeak)
129128
{
130129
PyLong obj = new PyLong(1024);

0 commit comments

Comments
 (0)
X Tutup