Why does heap size keep increasing?

别来无恙 提交于 2019-12-12 03:18:43

问题


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.

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.

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.


回答1:


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.

You could try the Leak Canary library. The lib can "watch" specifics objects and narrow the search for the leak.



来源:https://stackoverflow.com/questions/32492441/why-does-heap-size-keep-increasing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!