From 80435e19a8eb92718d6dc1ff9e6872ccd9c5db17 Mon Sep 17 00:00:00 2001 From: TobBrandt-Work Date: Fri, 10 Feb 2017 15:37:54 +0100 Subject: [PATCH] EventLoopScheduler: set _nextItem to null on Tick If _queue is empty after the item is removed from it, then _nextItem is never overriden and therefore keeps a reference to item. Until another action is scheduled with a future due time, the item and all its associated state is kept in memory. (cherry picked from commit 2679e8e9f10f2674cfa88fd7e13f7f1cea7d2172) --- .../src/System.Reactive/Concurrency/EventLoopScheduler.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs index b2d4ee95f2..b7701d7894 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs @@ -352,6 +352,10 @@ private void Tick(object state) if (!_disposed) { var item = (ScheduledItem)state; + if (item == _nextItem) + { + _nextItem = null; + } if (_queue.Remove(item)) { _readyList.Enqueue(item);