From 24b19c275cabb7f6c123231c508fcef63b52f444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20R=C3=B8rbech?= Date: Fri, 8 Sep 2023 14:36:09 +0200 Subject: [PATCH] Fix test around releasing intermediate versions (#1509) --- .../kotlin/io/realm/kotlin/test/android/MemoryTests.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/test-base/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/android/MemoryTests.kt b/packages/test-base/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/android/MemoryTests.kt index 2861a1e9f4..4caaaeabd8 100644 --- a/packages/test-base/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/android/MemoryTests.kt +++ b/packages/test-base/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/android/MemoryTests.kt @@ -149,14 +149,15 @@ class MemoryTests { // Perform various writes and deletes and garbage collect the references to allow core to // release the underlying versions + val referenceHolder = mutableListOf() for (i in 1..3) { - val referenceHolder = mutableListOf() - realm.writeBlocking { - for (i in 1..10) { + for (i in 1..10) { + val y: MemoryTest = realm.writeBlocking { copyToRealm(MemoryTest()).apply { stringField = oneMBstring - }.also { referenceHolder.add(it) } + } } + referenceHolder.add(y) } realm.writeBlocking { delete(query("stringField != 'INITIAL'"))