Skip to content

Commit 7cb359b

Browse files
committed
ensure weak refs are collect during gc_collect
1 parent 9db8b1e commit 7cb359b

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,7 @@ static long javaCollect(Node inliningTarget, GilNode gil) {
180180
Runtime runtime = Runtime.getRuntime();
181181
long freeMemory = runtime.freeMemory();
182182
try {
183-
PythonUtils.forceFullGC();
184-
try {
185-
Thread.sleep(15);
186-
} catch (InterruptedException e) {
187-
// doesn't matter, just trying to give the GC more time
188-
}
183+
CApiTransitions.ensurePollRefQueueCleanup();
189184
} finally {
190185
gil.acquire();
191186
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ public void exitCApiContext() {
958958
* deallocating objects may run arbitrary guest code that can again call into the
959959
* interpreter.
960960
*/
961-
CApiTransitions.exitPollCleanup();
961+
CApiTransitions.ensurePollRefQueueCleanup();
962962
PythonThreadState threadState = getContext().getThreadState(getContext().getLanguage());
963963
Object nativeThreadState = PThreadState.getNativeThreadState(threadState);
964964
if (nativeThreadState != null) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/CApiTransitions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public static PyCapsuleReference registerPyCapsuleDestructor(PyCapsule capsule)
408408
}
409409

410410
@TruffleBoundary
411-
public static void exitPollCleanup() {
411+
public static void ensurePollRefQueueCleanup() {
412412
PythonUtils.forceFullGC();
413413
PythonContext context = PythonContext.get(null);
414414
HandleContext handleContext = context.nativeContext;

0 commit comments

Comments
 (0)