不同手机/设备和操作系统版本上的 Android 堆大小

发布于 2024-10-23 23:09:48 字数 189 浏览 2 评论 0原文

有谁知道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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

も让我眼熟你 2024-10-30 23:09:48

从 build.prop 文件中提取的更多设备信息 (adb -d pull /system/build.prop):

手机(Android 版本):

  • HTC Wildfire (2.2.1) = 16MB
  • HTC Wildfire S (2.3.5) = 20MB
  • HTC Salsa (2.3.3) = 20MB
  • HTC Desire (2.3.3) = 32MB
  • HTC Desire S (2.3.5) = 32MB
  • Sprd - Richview - S111 (2.3.5) = 32MB
  • 三星 Galaxy S GT-I9000 (2.2) = 48MB
  • 三星Galaxy R GT-I9103 (2.3.5) = 64MB
  • 三星 Galaxy Y GT-S5360 (2.3.5) = 64MB
  • 三星 Galaxy Note N7000 (4.1.2) = heapstartsize=8m、heapgrowthlimit=64m、heapsize=256m
  • 三星 Galaxy S3 GT -I9300(4.3,xhpdi)= 8/64/256MB
  • 三星 Galaxy S4 GT-I9505(4.4,xxhpdi)= 8/128/512MB
  • 谷歌 Galaxy Nexus(4.3)= 8/96/256MB
  • 谷歌 Nexus 4(4.4,xhdpi) = 8/192/512MB
  • Google Nexus 5 (4.4, xxhdpi) = 8/192/512MB
  • Samsung Galaxy S6 SM-G920W8 (7.0) = 8/256/512MB

平板电脑 (Android 版本):

  • Samsung Galaxy Tab GT-P1000 (2.2) = 48MB
  • 三星 Galaxy Tab 8.9 GT-P7300 (3.2) =
  • 5/64/ 288MB 三星 Galaxy Tab 10.1 GT-P7500 (3.2) = 5/64/288MB
  • 三星 Galaxy Tab 3 10.1 GT-P5200 (4.2, mdpi) = 8/ 96/256MB
  • 宏碁 Iconia A500 (3.2.1) = 5/48/256MB
  • Kindle Fire HD 7" (4.0.3) = 5/48/256MB
  • 华硕 Transformer Prime TF201 (4.1.1) = 5/48/256MB
  • Nexus 10 (4.4.3) 16/192/512 MB

Some more device info extracted from build.prop files (adb -d pull /system/build.prop):

Phones (Android Version):

  • HTC Wildfire (2.2.1) = 16MB
  • HTC Wildfire S (2.3.5) = 20MB
  • HTC Salsa (2.3.3) = 20MB
  • HTC Desire (2.3.3) = 32MB
  • HTC Desire S (2.3.5) = 32MB
  • Sprd - Richview - S111 (2.3.5) = 32MB
  • Samsung Galaxy S GT-I9000 (2.2) = 48MB
  • Samsung Galaxy R GT-I9103 (2.3.5) = 64MB
  • Samsung Galaxy Y GT-S5360 (2.3.5) = 64MB
  • Samsung Galaxy Note N7000 (4.1.2) = heapstartsize=8m, heapgrowthlimit=64m, heapsize=256m
  • Samsung Galaxy S3 GT-I9300 (4.3, xhpdi) = 8/64/256MB
  • Samsung Galaxy S4 GT-I9505 (4.4, xxhpdi) = 8/128/512MB
  • Google Galaxy Nexus (4.3) = 8/96/256MB
  • Google Nexus 4 (4.4, xhdpi) = 8/192/512MB
  • Google Nexus 5 (4.4, xxhdpi) = 8/192/512MB
  • Samsung Galaxy S6 SM-G920W8 (7.0) = 8/256/512MB

Tablets (Android Version):

  • Samsung Galaxy Tab GT-P1000 (2.2) = 48MB
  • Samsung Galaxy Tab 8.9 GT-P7300 (3.2) = 5/64/288MB
  • Samsung Galaxy Tab 10.1 GT-P7500 (3.2) = 5/64/288MB
  • Samsung Galaxy Tab 3 10.1 GT-P5200 (4.2, mdpi) = 8/96/256MB
  • Acer Iconia A500 (3.2.1) = 5/48/256MB
  • Kindle Fire HD 7" (4.0.3) = 5/48/256MB
  • Asus Transformer Prime TF201 (4.1.1) = 5/48/256MB
  • Nexus 10 (4.4.3) 16/192/512 MB
但可醉心 2024-10-30 23:09:48

有谁知道 Android 手机上的堆大小是否是根据操作系统版本中设置的恒定值,或者这是否是手机生产商可以决定的设置?

从技术上讲,这是手机制造商可以决定的设置。安卓是开源的。我不记得兼容性定义文档中详细说明了堆大小要求,尽管我最近没有看过。

堆大小与手机上的 RAM 大小成正比吗?

不,它往往更多地基于屏幕分辨率,因为更高分辨率的屏幕往往想要操作更大的位图,因此 Google 提出了堆大小建议,希望设备制造商能够遵守。

我只找到了一些文章,人们说应用程序的堆大小是 16M。

[android]“堆大小” 上搜索 StackOverflow 会出现 这个答案

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?

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.

Is the heap size proportional to the amount of RAM on the phone?

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.

I've only found articles where people say that the heap size of an application is 16M.

Searching StackOverflow on [android] "heap size" turns up this answer.

无敌元气妹 2024-10-30 23:09:48

不仅是手机制造商,任何创建 Android 操作系统版本的人都可以根据其设备的具体要求指定允许的最大堆大小。一些 Android root,例如 CyanogenMod,甚至允许用户自己选择堆大小作为设置。

您可以使用以下方法检测允许的最大堆大小:

Runtime.getRuntime().maxMemory();

有关此主题的其他信息,请参阅

如果您的应用程序通常需要超过 16MB 的堆,建议的方法是在清单中设置最低操作系统版本级别,以确保下载您的应用程序的绝大多数人至少拥有您需要的数量,然后找到一种优雅地降低功能的方法,可以根据需要减少堆要求,降至 16MB 的基本水平,以便少数用户的堆数量低于最佳堆数量,从而落入该筛子。

以下是一些显示手机 RAM 与操作系统版本之间关系的数据(基于当前操作系统,而不是原始操作系统)。我相信至少有 1GB RAM 的手机几乎总是有超过 16MB 的堆。请注意,此处的百分比是支持指定内存的手机型号数量,而不是正在使用的手机总数,这可能会严重偏向某些型号。这些数字是通过将输入插入以下手机查找器(其中包括 1500 款 Android 手机型号)而获得的,因此只是大概数字:http://www.gsmarena.com/search.php3

按当前操作系统版本(不是发布时的版本)划分的具有至少 1GB RAM 的手机型号的百分比:

Phones running         Percent of models having at least 1GB of RAM   Percentage of all models
4.4 and up             100 percent                                    1.5
4.3 and up             100 percent                                    2.9
4.2.x and up           74 percent                                     18.7
4.1.x and up           71 percent                                     37
4.0 and up             62 percent                                     60
2.3.x and up           57 percent                                     71
2.2 and up             44 percent                                     93
2.1 and up             44 percent                                     97
ALL OS VERSIONS:       41.5 percent                                   100

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

Runtime.getRuntime().maxMemory();

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):

Phones running         Percent of models having at least 1GB of RAM   Percentage of all models
4.4 and up             100 percent                                    1.5
4.3 and up             100 percent                                    2.9
4.2.x and up           74 percent                                     18.7
4.1.x and up           71 percent                                     37
4.0 and up             62 percent                                     60
2.3.x and up           57 percent                                     71
2.2 and up             44 percent                                     93
2.1 and up             44 percent                                     97
ALL OS VERSIONS:       41.5 percent                                   100
风向决定发型 2024-10-30 23:09:48

您应该能够使用以下命令检查最大虚拟机堆大小:

getprop dalvik.vm.heapsize

在 Android 终端(connectbot 或 adb shell 等)。也可以重新挂载读写并在 build.prop 文件中设置堆大小。 (确保您安装了恢复功能,这样如果您不小心将其设置得太小,则可以重新设置它,从而无法启动)。

You should be able to check the max vm heapsize using:

getprop dalvik.vm.heapsize

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).

灰色世界里的红玫瑰 2024-10-30 23:09:48

允许应用程序使用的“VM 预算”因设备而异。平板电脑通常允许比手机更大的预算。

以下是我为各种设备找到的一些虚拟机预算大小。

  • G1 = 16 Mb
  • Droid = 24 Mb
  • Nexus One = 32 Mb
  • Xoom = 48 Mb
  • GalaxyTab = 64 Mb。

(注:如果您发现不同的情况,请告诉我)

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.

  • G1 = 16 Mb
  • Droid = 24 Mb
  • Nexus One = 32 Mb
  • Xoom = 48 Mb
  • GalaxyTab = 64 Mb.

(Note: if you've found differently, let me know)

柠北森屋 2024-10-30 23:09:48

实际上有一个定义的最小应用程序内存,具体取决于屏幕尺寸和密度:

移动设备的系统资源通常受到限制。安卓
设备的单个可用内存可低至 16MB
应用。 Android 兼容性定义文档 (CDD),
第 3.7 节。虚拟机兼容性给出了所需的最低要求
适用于各种屏幕尺寸和密度的应用程序内存。
应优化应用程序以在此最小内存下执行
限制。但是,请记住,许多设备都配置有更高的
限制。

引用自: 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

屏幕分类为中或的设备实现
低密度
必须配置 Dalvik 以分配至少 16MB 内存
到每个应用程序。屏幕的设备实现分类为
高密度或超高密度必须配置Dalvik来分配
每个应用程序至少 24MB 内存。请注意该设备
实现可能会分配比这些数字更多的内存。

对于现代版本,有一个表,它取决于屏幕密度等:

对于 Android 4.2,该表中的示例行:

小/正常/大尺寸和 xhdpi 密度:64MB

对于 Android 6,提取:

小/普通 xhdpi:80MB

小/普通 xxhdpi:128MB

小/普通 xxxhdpi:256MB

这些文档中也有其他 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:

Mobile devices typically have constrained system resources. Android
devices can have as little as 16MB of memory available to a single
application. The Android Compatibility Definition Document (CDD),
Section 3.7. Virtual Machine Compatibility gives the required minimum
application memory for various screen sizes and densities.
Applications should be optimized to perform under this minimum memory
limit. However, keep in mind many devices are configured with higher
limits.

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:

Device implementations with screens classified as medium- or
low-density
MUST configure Dalvik to allocate at least 16MB of memory
to each application. Device implementations with screens classified as
high-density or extra-high-density MUST configure Dalvik to allocate
at least 24MB of memory to each application. Note that device
implementations MAY allocate more memory than these figures.

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:

small / normal / large size and xhdpi density: 64MB

For Android 6, extract:

small/normal xhdpi: 80MB

small/normal xxhdpi: 128MB

small/normal xxxhdpi: 256MB

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/

负佳期 2024-10-30 23:09:48

这些数据对我有用。
选择模拟器平板电脑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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文