Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x: Flowable.blockingSubscribe(lambdas) is unbounded and can lead to OOME #5988

Closed
akarnokd opened this issue Apr 30, 2018 · 2 comments
Closed

Comments

@akarnokd
Copy link
Member

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 prefetch but leave the existing ones unbounded

Alternatively, this could be deferred until 3.x without worrying of the behavior change.

@RomanWuattier
Copy link
Contributor

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() and prefetch

WDYT? Can I work on this?

@akarnokd
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants