Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase android virtual device max heap size?

I would like to increase the android virtual device map heap size with Eclipse. I tried to set the Max VM application heap size to 128 in the Eclipse AVD Manager, but it does not work, the line Runtime.getRuntime().maxMemory()/(1024*1024); always returns 48, no matter the set heap size. Device ram size is set to 512. Selected target is Android 4.1.2 (API Level 16). Moreover, I have set android:largeHeap="true" in the manifest file.

Is there a limit to max heap size (is 128MiB to much ?), or is there another file to edit or parameter to set ?

like image 930
Fitz Avatar asked Jan 09 '13 09:01

Fitz


People also ask

How do I change RAM size in AVD?

Click on the Show Advanced Settings button to expose hidden things: 4. Scroll down a little bit to the Memory and Storage section. Here you can set your desired amount of RAM and memory.

How do I increase allocated heap size?

On Mac OSX one can easily change heap size by going to first menu item, Android Studio > preference > System Settings (left menu) > Memory Settings and change heap size there in the dialog.

What is VM heap in Android?

Memory Size and VM Heap. Memory size is the amount of memory the device should have specified in MB. Many phones today now have at least 1 GB of memory. 1 GB is equal to 1024 MB. The VM Heap specifies the heap size of the virtual machine in MB.


2 Answers

add large heap in Manifest file

<application

        android:icon="@drawable/example"
        android:label="@string/app_name" 
        android:largeHeap="true">

      ......
      ......

</application>
like image 118
ShreeshaDas Avatar answered Sep 30 '22 19:09

ShreeshaDas


To do that, in Eclipse, go to "Debug Configurations". You can find that in the drop-down under the "debug" icon. Select "target", and select a preferred emulator target to launch. Then under "additional emulator command line options," add this:

-partition-size 128

Then CLOSE the emulator (and remove any devices), and click the debug icon, which will launch the preferred emulator you selected. This is important: Eclipse needs to launch the debugger, not AVD.

Note that the size (128) is in megabytes.

Take a look also here: http://viralpatel.net/blogs/jvm-java-increase-heap-size-setting-heap-size-jvm-heap/

Or: increase the AVD RAM and the max VM application heap size in VM options: Go to Window-->AVD Manager-->Virtual Devices-->Edit.

like image 38
Milos Cuculovic Avatar answered Sep 30 '22 19:09

Milos Cuculovic