如何找出从内存转储的ID或preloaded系统可绘制(位图)名称 [英] How to find out IDs or names of preloaded system drawables (bitmaps) from memory dump

查看:213
本文介绍了如何找出从内存转储的ID或preloaded系统可绘制(位图)名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我分析了我们的应用程序的内存使用情况,并发现了奇怪的可绘制,其不断地吃堆几兆。以下是 MAT 的一些截图:

I'm analyzing memory usage of our app, and has found strange Drawables, which constantly "eats" few megabytes of heap. Here are few screenshots from MAT:

霸主与2 pretty的大位图的树

Dominator tree with 2 pretty big bitmaps

路径GC根以上的位图的一个

Path to GC roots for one of above bitmaps

此位图总是出现在堆从我的手机转储(三星GALAXY Nexus,OS 4.1.1 的),不管多久,我还是用我们的应用程序如何密集。

This bitmaps always appears in heap dumps from my phone (Samsung Galaxy Nexus, OS 4.1.1), no matter how long or how intensive I use our app.

我已经试图寻找使用MAT此位图源 - 没有运气。所有有用的信息,我能找到的是宽度高度的位图,它的512×512两种:

I've already tried to search the source of this bitmaps using MAT - with no luck. All usefull information I was able to find waswidth and height of bitmaps, it's both 512x512:

但是,我们的应用程序没有任何单一的512 * 512的可绘制。我想这是有些系统可绘制。但究竟是什么?为什么他们这么大?

But our app doesn't have any single 512x512 drawables. I assume this is some "system" drawables. But what exactly? Why them so big?

我也看了 android.content.res.Resources 类的源$ C ​​$ C,搜索取值$ P $的使用ploadedDrawables 字段 - 还没有运气。所有我从内存转储得到的 - 就是取值preloadedDrawables 数组,但我不能确定文件名从这个键或资源ID。

I've also looked at source code of android.content.res.Resources class, searching usage of sPreloadedDrawables field - also with no luck. All I get from memory dump - is key from sPreloadedDrawables array, but I can't determine filename or resource id from this key.

所以,我的问题是:

  • 我怎么能确定此位图名称或ID

什么这个巨大的位图被加载,为什么他们始终保持在内存中

更新

我已经找到一种方法来<一href="http://stackoverflow.com/questions/12709603/mat-eclipse-memory-analyzer-how-to-view-bitmaps-from-memory-dump">look在这个位图从内存转储。这两个位图是一个简单的渐变,一黑,等 - 白色。我想这是对 Holo.Light Holo.Dark ICS主题资源。但我的第二个问题是实际的还是:为什么这个位图始终保持在内存中?有什么办法来上传或回收呢?

I have found a way to look at this bitmaps from memory dump. This two bitmaps is a simple gradients, one black, other - white. I suppose this is resources for Holo.Light and Holo.Dark ICS themes. But my second question is still actual: why this bitmaps are always stays in memory? Is there any way to upload or recycle them?

推荐答案

我猜他们留在内存中,因为他们的默认背景的活动。尝试指定一个不同的背景,你的主题,看看他们是否仍然存在。

I would guess they stay in memory because they are the default backgrounds for activities. Try specifying a different background in your theme and see if they are still there.

这篇关于如何找出从内存转储的ID或preloaded系统可绘制(位图)名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆