不同手机/设备和操作系统版本上的 Android 堆大小
有谁知道Android手机上的堆大小是否是根据操作系统版本中设置的恒定值,或者这是手机生产商可以决定的设置?
堆大小与手机上的 RAM 大小成正比吗?
我只发现有人说应用程序的堆大小是 16M 的文章。然而,这些文章有点旧了。举个例子,据我所知,在一种特定模型上,堆大小从大约 20M 到 24M 不等。这款手机有768M RAM。
Does anyone know if the heap size on Android phones is a constant value according to what is set in the OS version or if this is a setting which the phone producers can decide on?
Is the heap size proportional to the amount of RAM on the phone?
I've only found articles where people say that the heap size of an application is 16M. However, these articles are a bit old. From what I see, as an example, heap sizes vary from around 20M up to 24M on one specific model. This phone has 768M of RAM.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
从 build.prop 文件中提取的更多设备信息 (adb -d pull /system/build.prop):
手机(Android 版本):
平板电脑 (Android 版本):
Some more device info extracted from build.prop files (adb -d pull /system/build.prop):
Phones (Android Version):
Tablets (Android Version):
从技术上讲,这是手机制造商可以决定的设置。安卓是开源的。我不记得兼容性定义文档中详细说明了堆大小要求,尽管我最近没有看过。
不,它往往更多地基于屏幕分辨率,因为更高分辨率的屏幕往往想要操作更大的位图,因此 Google 提出了堆大小建议,希望设备制造商能够遵守。
在
[android]“堆大小”
上搜索 StackOverflow 会出现 这个答案。Technically, it is a setting which the phone producers can decide on. Android is open source. I do not recall the Compatibility Definition Document spelling out heap size requirements, though I haven't looked recently.
No, it tends to be based more on screen resolution, as higher-resolution screens tend to want to manipulate larger bitmaps, so Google makes heap size recommendations that, hopefully, device manufacturers will abide by.
Searching StackOverflow on
[android] "heap size"
turns up this answer.不仅是手机制造商,任何创建 Android 操作系统版本的人都可以根据其设备的具体要求指定允许的最大堆大小。一些 Android root,例如 CyanogenMod,甚至允许用户自己选择堆大小作为设置。
您可以使用以下方法检测允许的最大堆大小:
有关此主题的其他信息,请参阅
如果您的应用程序通常需要超过 16MB 的堆,建议的方法是在清单中设置最低操作系统版本级别,以确保下载您的应用程序的绝大多数人至少拥有您需要的数量,然后找到一种优雅地降低功能的方法,可以根据需要减少堆要求,降至 16MB 的基本水平,以便少数用户的堆数量低于最佳堆数量,从而落入该筛子。
以下是一些显示手机 RAM 与操作系统版本之间关系的数据(基于当前操作系统,而不是原始操作系统)。我相信至少有 1GB RAM 的手机几乎总是有超过 16MB 的堆。请注意,此处的百分比是支持指定内存的手机型号数量,而不是正在使用的手机总数,这可能会严重偏向某些型号。这些数字是通过将输入插入以下手机查找器(其中包括 1500 款 Android 手机型号)而获得的,因此只是大概数字:http://www.gsmarena.com/search.php3
按当前操作系统版本(不是发布时的版本)划分的具有至少 1GB RAM 的手机型号的百分比:
Not only phone producers, but anyone who creates a version of the Android OS, can specify the maximum allowed heap size, based upon the specific requirements of their devices. Some Android roots, such as CyanogenMod, even allow the user to select the heap size herself as a setting.
You can detect the maximum allowed heap size using the method
Additional information on this topic is available here.
If your app normally needs more than 16MB of heap, a suggested approach would be to set a minimum OS version level in your manifest that ensures that the overwhelming majority of those downloading your app will have at least the amount that you need, and then find a way to degrade your functionality gracefully in a way that reduces your heap requirements as needed, down to a base level of 16MB, for the small number of users with less than your optimal amount of heap who fall through that sieve.
Here are some figures showing the association of phone RAM with OS version (based on current, not original, OS). I believe that a phone having at least 1GB of RAM will almost always have more than 16MB of heap. Note that the percentages here are for the number of phone models supporting the indicated memory, not total phones in use, which may be quite skewed toward certain models. These numbers were obtained by plugging inputs into the following phone finder (which includes 1500 Android phone models) and so are only ballpark figures: http://www.gsmarena.com/search.php3
Percentage of phone models having at least 1GB of RAM, by current OS version (not version at launch):
您应该能够使用以下命令检查最大虚拟机堆大小:
在 Android 终端(connectbot 或 adb shell 等)。也可以重新挂载读写并在 build.prop 文件中设置堆大小。 (确保您安装了恢复功能,这样如果您不小心将其设置得太小,则可以重新设置它,从而无法启动)。
You should be able to check the max vm heapsize using:
at Android terminal (connectbot or adb shell etc). It is possible to remount read-write and set the heap size in the build.prop file as well. (Make sure you have recovery installed so you can re-set it if you accidentally make it too small, it won't boot up).
允许应用程序使用的“VM 预算”因设备而异。平板电脑通常允许比手机更大的预算。
以下是我为各种设备找到的一些虚拟机预算大小。
(注:如果您发现不同的情况,请告诉我)
The "VM Budget" that an application is allowed to use varies from device to device. Tablets typically permit a larger budget than phones.
Here are some VM budget sizes I've found for various devices.
(Note: if you've found differently, let me know)
实际上有一个定义的最小应用程序内存,具体取决于屏幕尺寸和密度:
引用自: http://developer.android.com/training/displaying-bitmaps/ 但正如其他
人所说,每个设备制造商都会决定设备的实际值,因此它可能大于此值(但不能小于此值)。
上述兼容性定义文档 (CDD) 列出了每个 Android 版本的最低要求:
https://source.android.com/compatibility/cdd.html
获取最新版本Android 有一个 html 版本可用,我们可以直接链接到那里的运行时内存部分:
https://source.android.com/compatibility/android-cdd.html#3_7_runtime_compatibility :
对于 Android 2.3
对于现代版本,有一个表,它取决于屏幕密度等:
对于 Android 4.2,该表中的示例行:
对于 Android 6,提取:
这些文档中也有其他 Android 2.x、4.x、5.x 和 6 版本的表格(请参阅上面的 CDD 链接) 。
请参阅此谷歌链接以轻松查找特定设备的屏幕密度等:
https://design.google.com/devices/
There is actually a defined minimum application memory that depends on the screen size and density:
Quoted from: http://developer.android.com/training/displaying-bitmaps/index.html
But as others have stated, each device manufacturer decide the actual value for the device, so it could be greater than this (but not smaller).
The mentioned Compatibility Definition Document (CDD) listing the minimum requirements for each version of android:
https://source.android.com/compatibility/cdd.html
For the latest version of Android there is a html verison available, and we can directly link to the runtime memory section there:
https://source.android.com/compatibility/android-cdd.html#3_7_runtime_compatibility
For Android 2.3:
For the modern versions, there is instead a table where it depends on screen density etc:
For Android 4.2, example row from that table:
For Android 6, extract:
There is a table for the other Android 2.x, 4.x, 5.x and 6 versions too in those documents (see CDD link above).
Refer to this google link to easily find screen densities etc for specific devices:
https://design.google.com/devices/
这些数据对我有用。
选择模拟器平板电脑Android TV
内存 1536MB
虚拟机堆 16MB
内部存储 800MB
工作室管理 100
This data is working for me.
Select Emulator Tablet Android TV
RAM 1536MB
VM HEAP 16MB
Internal Storage 800MB
Studio -managed 100