diff --git a/runtime/src/main/kotlin/kotlin/collections/HashMap.kt b/runtime/src/main/kotlin/kotlin/collections/HashMap.kt index f968c6e901f..46d155a9752 100644 --- a/runtime/src/main/kotlin/kotlin/collections/HashMap.kt +++ b/runtime/src/main/kotlin/kotlin/collections/HashMap.kt @@ -13,9 +13,9 @@ class HashMap private constructor( override var size: Int = 0 private set - private var keysView: HashSet? = null - private var valuesView: HashMapValues? = null - private var entriesView: HashMapEntrySet? = null + // private var keysView: HashSet? = null + // private var valuesView: HashMapValues? = null + // private var entriesView: HashMapEntrySet? = null // ---------------------------- functions ---------------------------- @@ -85,30 +85,45 @@ class HashMap private constructor( } override val keys: MutableSet get() { - val cur = keysView - return if (cur == null) { - val new = HashSet(this) - keysView = new - new - } else cur + return HashSet(this) + + // Caching creates a reference cycle and thus leads to memory leaks; + // TODO: fix and enable. + + // val cur = keysView + // return if (cur == null) { + // val new = HashSet(this) + // keysView = new + // new + // } else cur } override val values: MutableCollection get() { - val cur = valuesView - return if (cur == null) { - val new = HashMapValues(this) - valuesView = new - new - } else cur + return HashMapValues(this) + + // Caching creates a reference cycle and thus leads to memory leaks; + // TODO: fix and enable. + + // val cur = valuesView + // return if (cur == null) { + // val new = HashMapValues(this) + // valuesView = new + // new + // } else cur } override val entries: MutableSet> get() { - val cur = entriesView - return if (cur == null) { - val new = HashMapEntrySet(this) - entriesView = new - return new - } else cur + return HashMapEntrySet(this) + + // Caching creates a reference cycle and thus leads to memory leaks; + // TODO: fix and enable. + + // val cur = entriesView + // return if (cur == null) { + // val new = HashMapEntrySet(this) + // entriesView = new + // return new + // } else cur } override fun equals(other: Any?): Boolean {