Problem with Java heap size

Monkey Targets Forums/Android/Problem with Java heap size

TeaBoy(Posted 2011) [#1]
Hi,

I've been having problems running the programs for Android due to the
Java heap, I have tried changing the heap size using ants ANT_OPTS environment variable to -Xmx512m -Xms512m with no success.

the message I receive is:

[apply] Error occurred during initialization of VM
[apply] Could not reserve enough space for object heap
[apply] Could not create the Java virtual machine.

any ideas on how to solve this?


DruggedBunny(Posted 2011) [#2]
Never seen anyone report this -- can you upload a copy of your project somewhere, or email it to Mark directly if it's confidential?


FlameDuck(Posted 2011) [#3]
Make sure your Android device has at least enough memory for the minimum Java Heap space. Depending on what version of Android you're running you should probably have at least 128 megs of RAM on your device.

The options you're trying to change are the Java VM initial (Xms) and maximum (Xmx) heap space. If you set it to 512 megabyte you need 512 megabytes of unfragmented free memory on the device.


DruggedBunny(Posted 2011) [#4]
Whoa, welcome back, Mikkel!


TeaBoy(Posted 2011) [#5]
arghhhhhhhhh!!!!!!!!!!!!! LOL

what a pain in the ar*e!

ok, many thanks for the suggestions thus far, it certainly was a memory issue, absolutely *NOT* a bug with Monkey (didnt even think this).

Solved it by editing 'dx.bat' within platform-tools of the android sdk directory.

a few lines down the file, you will see:

REM By default, give dx a max heap size of 1 gig. This can be overridden
REM by using a "-JXmx..." option (see below).
set defaultMx=-Xmx512M <-- this was initially 1024 so reduced it.

it all works fine!

so it anyone has any problems like I did, try this first, should save alot of head scratching!