android - 为什么一个基本的 Android 应用程序在内存中有数百个位图?

标签 android android-bitmap android-memory

在构建我的第一个 Android 应用程序时,我注意到应用程序启动时内存使用量已经接近 20MB。我下载了 Eclipse MAT 并查看了内容,发现内存中有成百上千的位图。其中许多并没有直接在我的项目中使用(至少没有我知道的那么多)

最大图像为 9MB: https://imagebin.ca/v/2eCK4JYLO2f2

其他的要小得多: https://imagebin.ca/v/2eCMmbFuIWsz

Android 似乎已经竭尽全力通过使用 zygote 来减少内存...那么为什么内存中已经有这么多未使用的位图?

(基本项目是使用 Android Studio 的空白 Activity ,其 fragment 由 TextView 组成,简单地说“Hello World!”)

最佳答案

我发现位图来自 Zygote 的内存占用。由于所有基于 java 的应用程序都是通过 zygote 启动的,这意味着最小内存使用量由 Zygote 使用的内存大小决定,而 Zygote 又取决于设备的显示密度。

找到的答案:
Find the class that wastes memory
Locate & remedy cause of large heap size

关于android - 为什么一个基本的 Android 应用程序在内存中有数百个位图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36699202/

相关文章:

android - 如何在 Glide 的帮助下将 Arraylist<Bitmap> 作为输出?

android - Vector Drawable 内存效率高吗?

Android 错误 : java. lang.OutOfMemoryError: bitmap size exceeds VM budget

android - 方向更改后, fragment 对 mActivity 的引用变为空。无效的 fragment 状态维护

java - List<Trail> 无法转换为 Context

android - 在 Android 的特定时间开始过渡?

android从 Assets 中获取位图或声音

android - 如何强制Android上的内存泄漏导致崩溃?

java - Android 为什么不能在 Toolbar 中使用 TextView

android - 确定目标API