diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index cfa46aeeb2f..a9a6b5d7de2 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -2205,6 +2205,10 @@ task memory_weak1(type: RunKonanTest) { source = "runtime/memory/weak1.kt" } +task memory_only_gc(type: RunStandaloneKonanTest) { + source = "runtime/memory/only_gc.kt" +} + task mpp1(type: RunStandaloneKonanTest) { source = "codegen/mpp/mpp1.kt" flags = ['-tr', '-Xmulti-platform'] diff --git a/backend.native/tests/runtime/memory/only_gc.kt b/backend.native/tests/runtime/memory/only_gc.kt new file mode 100644 index 00000000000..b2da7c12861 --- /dev/null +++ b/backend.native/tests/runtime/memory/only_gc.kt @@ -0,0 +1,4 @@ +fun main(args: Array) { + konan.internal.GC.collect() +} + diff --git a/runtime/src/main/cpp/Memory.cpp b/runtime/src/main/cpp/Memory.cpp index de002dfa648..ed940f2c49f 100644 --- a/runtime/src/main/cpp/Memory.cpp +++ b/runtime/src/main/cpp/Memory.cpp @@ -1358,6 +1358,8 @@ void GarbageCollect() { state->gcInProgress = true; + processFinalizerQueue(state); + while (state->toFree->size() > 0) { CollectCycles(state); processFinalizerQueue(state);