Reputation: 3193
If I have infinite animation in activity and navigate away from activity, does it causes memory leak? Do I have to stop animation explicitly or is it somehow managed on framework level? What I mean by infinite animation:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:repeatCount="infinite">
<rotate
android:duration="1000"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
Upvotes: 4
Views: 3683
Reputation: 853
Not closely related, but If the leak is caused by the Animator class, e.g. holding a reference to an Activity/Fragment, you should call animatorInstance.removeAllListeners()
in your fragment/activity onDestroy
callback.
Upvotes: 0
Reputation: 8023
From developers webpage :
You should usually use the onPause() callback to: Stop animations or other ongoing actions that could consume CPU.
Source : http://developer.android.com/training/basics/activity-lifecycle/pausing.html#Pause
Upvotes: 1