I've recently gotten into android development, and I've been taking some of the Android basics courses offered on Udacity. I've tried using their forums, but I haven't really had much success, so I'm asking here!
Currently I'm on the fourth course which covers networking. One of the lessons goes over asynchronously loading data using the AsyncTask class first, then loaders. Part of the reasoning for using loaders over AsyncTasks is that the latter can potentially cause memory leaks if, for example, the phone's orientation changes while it's retrieving data. Loaders supposedly don't have this issue. Using the monitors on Android Studio, I checked how much memory was being used whenever I changed the orientation of the demo app for the course when I was using loaders. The amount of free memory would go down during the orientation changes regardless.
I tried the same thing using just the empty app template, and the same thing would happen; The amount of free space displayed on the monitor would go down, and the amount of allocated space would go up. The number of free space doesn't go back down until I click the little "initiate garbage collector" icon on the monitor. From what I've read, I understand that on orientation changes, activities are destroyed (confirmed this by logging a message on the Activity's onDestroy() callback, then switching orientation) and then recreated. But shouldn't the memory used by the activity that was destroyed be released? Why/Why not?
Thanks!
I know someone else asked a similar question, but it still doesn't answer my question (shouldn't the memory used by the activity that was destroyed be released?)