I think you are missing one important thing: For the first example to become a memory leak, you…
Frode Nilsen

I don’t think the MainActivity is referencing the AsyncTask, because there’s no MainActivity class member which has a reference to the AsyncTask. The AsyncTask can’t be accessed anymore after the onCreate method of the MainActivity is finished. Let me know if I’m wrong.

Like what you read? Give Oleksandr Melnykov a round of applause.

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