How to leak memory with Subscriptions in RxJava
Marcin Robaczyński

The safest approach to hold direct or indirect references to an Activity in presenters is to store them in a WeakReference and always check weakRef.get() != null before using them. That doesn’t mean you don’t need to detach the view in you presenter’s destroy()/dispose()/detach() method (through weakRef.clear()), but in the case where your presenter’s view WeakReference objects ends being reachable through another GC root (typically another thread) your Activity still can be reclaimed by the GC.

Like what you read? Give Fernando Herrera a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.