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'"))