1.布局中有帧动画导致内存溢出。加载动画的时候是会先把图片全部加载到内存中
a.布局中src先不要写动画文件,使用的时候才加载
b.所以首先一点要压缩图片的空间
c.可以减少图片张数
<ImageView android:id="@+id/video_guide_image" android:layout_width="wrap_content" android:layout_height="wrap_content" tools:src="@drawable/mkz_comic_video_guide_animation"/>
private void startVideoGuideAnimation() { guideVideoView.setVisibility(View.VISIBLE); guideVideoImageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.mkz_comic_video_guide_animation));//使用的时候才加载指明 if (guideVideoImageView != null && guideVideoImageView.getDrawable() instanceof AnimationDrawable) { ((AnimationDrawable) guideVideoImageView.getDrawable()).start(); } ReadSettingStore.setHasShowVideoGuide(this); }
//未完待续,持续更新中
2.频繁GC 为什么会导致卡顿
GC的时候主线程是会停顿去做GC的,频繁GC就会导致主线程卡顿,要尽量避免频繁GC