File tree 1 file changed +6
-2
lines changed
kotlinx-coroutines-core/common/src/channels
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1690,8 +1690,12 @@ 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 and clean the corresponding field to avoid memory leaks.
1695
+ * This nulling out cleans up iterator's waiters (i.e. `hasNext()` callers) when the channel is closed.
1696
+ * Without this cleanup, waiters will be GC-reacheable even when the channel is already closed and
1697
+ * waiters are successfully resumed.
1698
+ */
1695
1699
val cont = this .continuation!!
1696
1700
this .continuation = null
1697
1701
// Update the `hasNext()` internal result and inform
You can’t perform that action at this time.
0 commit comments