关于Android 内存泄露的问题
天蓬老师
天蓬老师 2017-04-17 17:38:10
0
2
501

如果我在SampleActivity里面定义了一个成员变量ValueAnimator mAnimator,并设置重复方式为无限重复:mAnimator.setRepeatCount(ValueAnimator.INFINITE),将其启动:mAnimator.start();。那么问题来了:当SampleActivity已经销毁后,通过Logcat发现mAnimator还在运行,这样会不会导致Activity内存泄露?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
伊谢尔伦

The definition of Activity memory leak is that after the Activity is closed, whether there are other resident objects referencing the Activity object, causing the Activity object not to be recycled.
From the information you gave, we can’t tell whether it will cause a memory leak, because you didn’t give whether mAnimator references Activity.
You can directly check the reference chain of mAnimator. If there is a reference to the Activity object (for example, the View operated by ValueAnimator and the callback object of ValueAnimator may cause indirect references to the Activity), it will cause a memory leak.

刘奇

You can use log to print logs. For example, write a log in the onDestroy method to see if it is called. Print the log in a loop in the activity to see if the log printing will stop after closing.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template