Getting I/art: Explicit concurrent mark sweep GC freed

好久不见. 提交于 2019-12-02 23:23:22

All this means is that the garbage collector is doing its job and freeing up memory.

If you are seeing this frequently (or consistently), then you are likely allocating too many objects. A common cause is allocating many (or a few large) objects within a loop like so:

for (int i = 0; i < 100; i++) {
    Bitmap bmp = Bitmap.create(100, 100, Bitmap.Config.ARGB_4444);
}

Every time we hit this loop, we allocate one hundred new Bitmap objects.

The best way to prevent GC sweeps is to not allocate objects. Of course you have to allocate objects in Java, so you need to ensure that you are not allocating unnecessarily.

Here is one of many YouTube videos that Google has release with tips on avoiding GC events and managing memory properly.

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