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

Aggressive GC for WeakReference on Android starts from 2.3 #58

Closed
Gwindor opened this issue Nov 19, 2014 · 4 comments
Closed

Aggressive GC for WeakReference on Android starts from 2.3 #58

Gwindor opened this issue Nov 19, 2014 · 4 comments

Comments

@Gwindor
Copy link

Gwindor commented Nov 19, 2014

I read RxAndroid sources a bit and when I reached this classes (https://github.com/ReactiveX/RxAndroid/blob/0.x/library/src/main/java/rx/android/functions/ViewAction1.java) I start worried about how using WeakReferences can afect application on real device and production application. Also weak refereces used in more important place like this (https://github.com/ReactiveX/RxAndroid/blob/0.x/library/src/main/java/rx/android/operators/OperatorViewClick.java)

Here is a reason (http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html#memory-cache, note section).

@ronshapiro
Copy link
Contributor

What's there to be worried about? The aggressiveness of GC doesn't change the fact that when a GC pass occurs, the object being referenced by the WeakReference is either referenced in other locations or not.

@ronshapiro
Copy link
Contributor

That link says that weak/soft references are bad for caches, but here we explicitly don't want to hold on to our reference for longer than we need it.

@mttkay
Copy link
Collaborator

mttkay commented Nov 19, 2014

What @ronshapiro said. This has nothing to do with caching but with not accidentally leaking Context.

@Gwindor let me know if that addresses your concerns!

@JakeWharton
Copy link
Member

Closing. Comment if you have more concerns or open a new issue.

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

No branches or pull requests

4 participants