-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Memory leak #15
Comments
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
|
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:
Kill the process - helps to fix the issue. |
This was a red herring and not caused by the Rx activity. Basic fragment construction + backstack was at fault
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 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. |
Yes, the issue is resolved. Thanks for your contribution to RxJava tutorials! The examples are clear and useful! :) |
Hi Kaushik, thanks for yours examples about RxJava. I`ve just started learning it. I investigated RxJava with Retrofit, and found an issue. When the request being done to server, an exception is thrown with 403 error. onError called, an exception logged. looks Ok.
The issue is - when I close the app with back button, and open again, and do the request again, exception is thrown, and 2 errors was logged. Do the same steps, onError was called, 3 erros was logged, etc. Memory leak occurs.
Firstly - it seems strange, the Observable finished with an error, onError was called, app was closed with back button, onDestroy was called, all objects should be garbage collected.Isn't it ?
Ok, I tried to call unsubscribe on OnDestroy, the issue still reproduce.
I googled the issue and found workaround using WeakReference. It looks awkwardly.
What is your opinion about this ? Or, I did something wrong ?
The text was updated successfully, but these errors were encountered: