File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
kotlinx-coroutines-core/common/src/channels Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1690,8 +1690,11 @@ internal open class BufferedChannel<E>(
1690
1690
}
1691
1691
1692
1692
fun tryResumeHasNextOnClosedChannel () {
1693
- // Read the current continuation and clean
1694
- // the corresponding field to avoid memory leaks.
1693
+ /*
1694
+ * Read the current continuation of the suspended `hasNext()` call and clean the corresponding field to avoid memory leaks.
1695
+ * While this nulling out is unnecessary, it eliminates memory leaks (through the continuation)
1696
+ * if the channel iterator accidentally remains GC-reachable after the channel is closed.
1697
+ */
1695
1698
val cont = this .continuation!!
1696
1699
this .continuation = null
1697
1700
// Update the `hasNext()` internal result and inform
You can’t perform that action at this time.
0 commit comments