You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Observable.Generate leaks a SerialDisposable every iteration. For example:
var scheduler = Scheduler.Default;
Observable.Generate<int, int>(
0
, i => i < 12000
, i => i + 1
, i => i
, i => scheduler.Now,
scheduler).Subscribe();
Gives a StackOverflowException instantly. Notice I use scheduler.Now to speed up the problem, using any timespan below 1 ms works, as at that span, Observable.Generate goes to the next iteration instantly. If you use a timespan at or above 1ms, it switches to 10-15ms delays (the precision of Windows timers).
Gives a out of memory exception after 8 seconds. If you increase the delay to 1-15ms, i estimate it will run out of memory at after 80-800 hours, however did not have time yet to leave it running for a month, the memory profiler still shows leaked objects.
The text was updated successfully, but these errors were encountered:
I can confirm that this is a problem. I just tracked down a memory leak in our application to Observable.Generate(), seems to be the exact same issue as reported here.
Dorus
changed the title
StackOverflowException in Observable.Generate
Memory leak in Observable.Generate results in StackOverflowException or OutOfMemoryException
Jul 1, 2015
+1 I had the same problem with Generate and timer below 1ms.
It generates a chain of disposable[] which points to the previous one creating a concatenation so long that both VS2015 debugger and windbg + sos crash if the dump is moderately long.
Observable.Generate leaks a SerialDisposable every iteration. For example:
Gives a StackOverflowException instantly. Notice I use scheduler.Now to speed up the problem, using any timespan below 1 ms works, as at that span, Observable.Generate goes to the next iteration instantly. If you use a timespan at or above 1ms, it switches to 10-15ms delays (the precision of Windows timers).
Another example:
Gives a out of memory exception after 8 seconds. If you increase the delay to 1-15ms, i estimate it will run out of memory at after 80-800 hours, however did not have time yet to leave it running for a month, the memory profiler still shows leaked objects.
The text was updated successfully, but these errors were encountered: