There are 8 activities in my app, all of them have an animated background that I initialize as follows. If I remove this bit of code, the memory usage according to the AS profiler will keep pretty much steady when switching between activities. If I keep the animation running, the memory usage keeps increasing everytime I switch between activities to a point that is just unsustainable.
anim = (AnimationDrawable) linearLayout.getBackground();
anim.setEnterFadeDuration(3000);
anim.setExitFadeDuration(10000);
anim.start();
I tried adding finish() and anim.stop() at the end of every activity, also tried to put an anim.setCallback(null); with no result. You can see in the screenshot the spikes when an activity gets called. So I think I succeded on identifying where the problem is, but I cannot find a way to solve it.
The animation has 4 frames, each one with a png of about 400kb size.
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/backexpo1"
android:duration="10000" />
<item
android:drawable="@drawable/backexpo2"
android:duration="10000" />
<item
android:drawable="@drawable/backexpo3"
android:duration="10000" />
<item
android:drawable="@drawable/backexpo4"
android:duration="10000"
/>
