Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a minimal heap size for Android versions?

Many posts have talked about Android heap size, and so far what I've found out is that the only common thing about max heap size is that it's at least 16MB, but that was the limit ever since API 3. For using more memory, people would suggest to use the NDK or anything that is beyond the "normal" Android development.

Is there any Android version that has a requirement from the devices to have a larger heap size, so that I could start assuming a larger one and stop being so cheap on memory?

Is there also a requirement about the flag of the large heap (from API 11 - honeycomb) inside the manifest, or is it a vague request that the device might even ignore it?

It's just that the Android hardware has improved so much over the years, yet we still need to be so cheap on memory even though devices now have more than 1GB of ram. And it's weird that we can't ask from the OS to get us a specific amount of heap size and promise it that we won't use any more of this.

like image 535
android developer Avatar asked Jan 17 '13 09:01

android developer


People also ask

What is Android heap size?

By default, Android Studio has a maximum heap size of 1280MB. If you are working on a large project, or your system has a lot of RAM, you can improve performance by increasing the maximum heap size for Android Studio processes, such as the core IDE, Gradle daemon, and Kotlin daemon.

Does the heap have a limit?

The default startup heap size is 1.5 GB. This value must be a number between 1.5 GB and the maximum amount of memory allowed by your operating system and JVM version. Consider the following examples: If you have a Windows system with a 32-bit JVM, then a process can have a maximum heap size of 2 GB.

What is a heap limit?

The heap size is the amount of memory allocated to objects that are being defined in your Apex code. And Apex code puts in a limit to the total allowed size of the apex heap size. This governor limit is calculated at runtime and depends on how the governor is invoked.

What is the size of heap memory?

Initial heap size is 1/64th of the computer's physical memory or reasonable minimum based on platform (whichever is larger) by default. The initial heap size can be overridden using -Xms. Maximum heap size is 1/4th of the computer's physical memory or 1 GB (whichever is smaller) by default.


1 Answers

ok, i've finally found the answer (thanks to this post) :

the bare minimal for all versions of android (including 5) , is 16MB.

the requirements for each of the android versions can be read about here:

http://source.android.com/compatibility/downloads.html

you can read about them by opening the CDD files and searching for "Runtime Compatibility" (or "Virtual Machine Compatibility" for old versions). also, you can find the minimal RAM requirement by searching for "Memory and Storage", but i think it's only the requirement for the system itself.

so, for example, on 4.0.3 - 5 the minimal heap size is:

  • 16MB: small/normal with ldpi/mdpi, or large with ldpi
  • 32MB: small/normal with tvhdpi/hdpi, or large with mdpi
  • 64MB: small/normal with xhdpi, or large with tvdpi/hdpi, or xlarge with mdpi.
  • 96MB: small/normal with 400dpi, or xlarge with tvhdpi/hdpi
  • 128MB: small/normal with xxhdpi, or large with xhdpi
  • 192MB: small/normal with 560dpi, or large with 400dpi, or xlarge with xhdpi .
  • 256MB: small/normal with xxxhdpi, or large with xxhdpi
  • 288MB: xlarge with 400dpi
  • 384MB: large with 560dpi, or xlarge with xxhdpi
  • 512MB: large with xxxhdpi
  • 576MB: xlarge with 560dpi
  • 768MB: xlarge with xxxhdpi

I can't find the minimal heap size for versions 3.x but it's probably the same as 4.0.3 .

for 2.1 - 2.3 , the minimal heap size is :

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.

meaning:

  • medium screen or ldpi - 16MB
  • hdpi or xhdpi - 24MB

i can't find the minimal heap size for version 1.6 , but it's probably the same as 2.1 .

also, i can't find out what should the large-heap flag do for each of the android versions (since 3.0) .

like image 107
android developer Avatar answered Oct 20 '22 03:10

android developer