• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android Compiling error "OutOfMemoryError: Java heap space"

vortexvt

Member
I set "JDK Max heap size (in GB)" to 1, 2, 4, 8, 32. It still fail to build game.
This is part of log from output window.

Code:
Running dex as a separate process.

To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 33280 MB (based on the dexOptions.javaMaxHeapSize = 32g).
To do this set org.gradle.jvmargs=-Xmx33280M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html

:org.vortexcannon.LastMan:mergeDebugJniLibFolders
:org.vortexcannon.LastMan:transformNative_libsWithMergeJniLibsForDebug
:org.vortexcannon.LastMan:processDebugJavaRes UP-TO-DATE
:org.vortexcannon.LastMan:transformResourcesWithMergeJavaResForDebug
:org.vortexcannon.LastMan:validateSigningDebug
:org.vortexcannon.LastMan:packageDebug
Expiring Daemon because JVM Tenured space is exhausted
Daemon will be stopped at the end of the build after running out of JVM memory
Exception in thread "pool-7-thread-1" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3236)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
    at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
    at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
    at java.io.FilterOutputStream.write(FilterOutputStream.java:97)
    at com.android.builder.internal.packaging.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:70)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:55)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor$$Lambda$225/575637572.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "pool-7-thread-2" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3236)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
    at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
    at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
    at java.io.FilterOutputStream.write(FilterOutputStream.java:97)
    at com.android.builder.internal.packaging.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:70)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:55)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor$$Lambda$225/575637572.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "pool-7-thread-3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-4" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-5" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-6" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-7" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-8" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-9" java.lang.OutOfMemoryError: Java heap space
Expiring Daemon because JVM Tenured space is exhausted
Exception in thread "pool-7-thread-10" java.lang.OutOfMemoryError: Java heap space
Daemon is stopping immediately JVM garbage collector thrashing and after running out of JVM memory

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon has been stopped: JVM garbage collector thrashing and after running out of JVM memory

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


C:\Windows\system32\cmd.exe DONE (1)
C:\Windows\system32\subst.exe /d Z:


C:\Windows\system32\subst.exe DONE (0)
System.Exception: Build Failed
   в ..(Dictionary`2 , String , String , Boolean )
   в Igor.AndroidBuilder.Package()Igor complete.
elapsed time 00:05:11.2807770s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.0.6.93/bin/Igor.exe" -options="C:\Users\Vortex\AppData\Local\GameMakerStudio2\build.bff"  -- Android Package started at 05/10/2017 10:53:24
FAILED : Package Program Complete
 
T

Tayler Wilbourn

Guest
I'm having the same error, and have tried the same fix, along with cleaning and rebuilding. Gradle seems to think it still only has 1GB allocated.

Code:
To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
I can add that the build works fine in GMS1.4, and is only failing after the import to GMS2.
 

vortexvt

Member
I was able to fix this error myself.

I created file "gradle.properties" with settings:

org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx12800M
org.gradle.configureondemand=true

Copied it to C:\Users\***\.gradle
 
T

Tayler Wilbourn

Guest
That solution worked perfectly, thanks!
If you could, adding [SOLVED] to the thread title would help others with the same problem find this fix. It doesn't seem to be anywhere else on the forums.
And thanks again for the quick reply. This was a direct blocker to development for me.
 

Slyddar

Member
I was able to fix this error myself.

I created file "gradle.properties" with settings:

org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx12800M
org.gradle.configureondemand=true

Copied it to C:\Users\***\.gradle
Thanks for this help. Got the same error today straight after I added about 70Mb of music files to my game. Created the file, copied it to the c:\users\<username>\.gradle folder and it worked. Crazy that we even need to do this though. Should be reported as a bug in GM2.
 
G

gbriozzo

Guest
OMG i love you guys, it worked after 6 hours of searching
 
K

kyropim

Guest
This worked! thank you so much!
edit: I used GMS1 and this one worked!
 
Last edited by a moderator:

ridho_h

Member
I was able to fix this error myself.

I created file "gradle.properties" with settings:

org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx12800M
org.gradle.configureondemand=true

Copied it to C:\Users\***\.gradle
Thank you. I was having the same problem and this solution works perfectly.
 

nanocore

Member
I was able to fix this error myself.

I created file "gradle.properties" with settings:

org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx12800M
org.gradle.configureondemand=true

Copied it to C:\Users\***\.gradle
It worked like a charm.
Thank you so much!
 
Top