问题描述
我有了很多的涟漪效果和动画的应用程序。
I have an application that has a lot of ripple effects and animations.
我试图来回多个屏幕,并且还垃圾邮件点击按钮。
I tried going back and forth multiple screens, and also spam clicking buttons.
我注意到,堆大小不断上升,尽管有些画面已经被关闭。
I noticed that the heap size continuously goes up even though some screens have already been closed.
当我检查了堆转储,以最高的保留堆是在 android.graphics.Bitmap
类,并指向所有的按钮我点击,有一个类连锁反应。
When I checked the heap dump, the class with the highest Retained heap was the android.graphics.Bitmap
class and points to all of the buttons I clicked that has a Ripple Effect.
按钮上的涟漪效应只是简单的涟漪,它使用?ATTR / selectableItemBackgroundBorderless
作为背景。但它上升由0.3MB或0.5MB按钮中的每次点击与涟漪。
The Ripple Effects on the buttons are just simple ripples which uses ?attr/selectableItemBackgroundBorderless
as the background. But it goes up by 0.3mb or 0.5mb on every click of the buttons with ripples.
推荐答案
可能是某种形式的MemoryLeak。这几乎是不可能告诉哪里出了问题,而不analise的code。我推荐一些测试。
Could be a MemoryLeak of some kind. It's almost impossible to tell where is the problem without analise the code. I recommend some tests.
您可以尝试库。的lib可以看具体对象,缩小了泄漏搜索。
You could try the Leak Canary library. The lib can "watch" specifics objects and narrow the search for the leak.
这篇关于为什么堆大小不断增加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!