Comments (4)
Hiya.
Sure let's try to break it down and get to the bottom of the issue.
The first problem you described seems like your not unsubscribing from the
observable at the end of the life cycle. Help me answer these questions:
- Did you pull the latest code from the repo? (I recently pushed some
fixes) - Which example specifically are you trying ? Give me the name of the
class from the sample repo.
from rxjava-android-samples.
- No, I didn`t.
- I was trying the RetrofitFragment.
The interesting thing is that I unsubscribe on OnDestroy of that fragment. In the example the Observable was not unsubscribed, so, I created the local Subscriber, init it by button click, and unsubscribe on OnDestroy.
I have just pulled the changes and the issue still reproducing. I was debugging and the Observable is being unsubscribed.
Steps to reproduce:
- Turn off the internet (to simulate no internet connection exception)
- Open the Retrofit-RxJava example.
- Press the button.
- onError observer is called. Error logged.
- close the app with back button.
- do 2,3 steps
- two onError is called. 2 Error logged.
Kill the process - helps to fix the issue.
Looks like Observable holds the Activities reference, even app was closed with back button.
from rxjava-android-samples.
excellent catch! couple of points:
a. the "leak" was not being caused by any of the Rx activity. so the Retrofit + RxJava combination was not causing any of the issues. I tested this by removing all Rx related stuff from the fragment and placing a debug log statement in the onResume
method. You'll notice multiple instances of the fragment being created.
b. while i cannot pinpoint and tell you exactly what went wrong, i cleaned up the fragment construction and the backstack behavior. This solved the problem. If you have a look at #a0b2e2d you'll see the differences. Essentially i remove the useless activity_main layout, and when adding fragments i use android.R.id.content
instead of a custom id.
Needless to say, post cleanup, the multiple fragment instance logs didn't show up.
i'm going ahead and closing this issue. thanks for letting me know. if you're still facing issues, let me know and i'll reopen.
from rxjava-android-samples.
Yes, the issue is resolved.
Thanks for your contribution to RxJava tutorials! The examples are clear and useful! :)
from rxjava-android-samples.
Related Issues (20)
- Observables Context?? HOT 1
- Rxjava 2 with Android new architecture components HOT 2
- Exceeds Dex Limit of 64k in its current state. HOT 1
- [Question] Help Needed HOT 1
- gc overhead limit exceeded?
- Mocking framework
- memory leak
- Wrapping an Android Method that requires return value
- Code of Examples
- After value change -> execute once HOT 5
- What does RotationPersist1WorkerFragment and RotationPersist2WorkerFragment do? HOT 1
- networkObserver get Exception so the final result is onError in your example when network fail even if localObeserver has data HOT 3
- Port to RxJava 2.0 HOT 12
- RxJava2: Create an examples handing backpressure HOT 2
- takeUntil optimized cache and network method and Gson parse model HOT 2
- RxJava 1 branch HOT 1
- Have you stopped maintaining this project? HOT 2
- GUI elements must not be accessed from non-main threads HOT 1
- You are using a private api (as of support library v25 and up) HOT 1
- Retrolambda is too difficult for beginners HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxjava-android-samples.