2.x: Flowable.blockingSubscribe(lambdas) is unbounded and can lead to OOME
I can't remember why, but Flowable.blockingSubscribe(Consumer,...) uses unbounded requests, which can lead to OutOfMemoryError in both synchronous and asynchronous scenarios.
The problem was raised in this StackOverflow question and apart from the obvious solutions, having such unbounded operator over an asynchronous boundary can be a problem regardless.
Possible resolutions:
- Behavior change: bound it to
bufferSize()in 2.x - (and/or) Introduce overload(s) with
prefetchbut leave the existing ones unbounded
Alternatively, this could be deferred until 3.x without worrying of the behavior change.
Flowable.blockingSubscribe(Consumer,…) is using Functions.MaxRequestSubscription() which could lead to OutOfMemoryError. Is it the issue?
In that case, I suggest to:
- Keep existing
Flowable.blockingSubscribe(Consumer,…)unbounded - Deprecate existing
Flowable.blockingSubscribe(Consumer,…) - Introduce new overloads with
bufferSize()andprefetch
WDYT? Can I work on this?
Create a new overload:
blockingSubscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError, Action onComplete, int bufferSize)
have a dedicated implementation servicing it and leave the other overloads unbounded.