Sep 6, 2018 · 1 min read
As you said in the article, calling retrofit in the way MoviesActivity did causes memory leak. I created a static inner class that calls retrofit in a background thread with execute() method and I got rid of the memory leak. However, the android advice is to use ViewModel in this case so when the activity is rotated it does not need to make a call again because the data is saved in the instance. Here is the question, does use a ViewModel can cause memory leak? I think not, because even if the user rotates the screen multiple times before the call is finished, the ViewModel makes the call only once. What do u think about that?
