Android build fails with Java heap space error

Project is heavy with images. IOS build is around 300 MB size. Problem with Android build happens with both Windows and Mac devices.

Here is logs for the fail. I can add Defold team member to project if needed for testing.

I use latest Defold build.

!SESSION 2017-01-17 14:50:18.475 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments: -keyring /Users/seepia/.eclipse_keyring -showlocation
Command-line arguments: -os macosx -ws cocoa -arch x86_64 -keyring /Users/seepia/.eclipse_keyring -showlocation

!ENTRY org.eclipse.core.resources 4 2 2017-01-17 14:56:07.230
!MESSAGE Problems occurred when invoking code from plug-in: “org.eclipse.core.resources”.
!STACK 1
org.eclipse.core.runtime.CoreException: Build failed: Java heap space
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:177)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
… 13 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more
!SUBENTRY 1 com.dynamo.cr.editor 4 75 2017-01-17 14:56:07.231
!MESSAGE Build failed: Java heap space
!STACK 0
com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more
!SUBENTRY 1 com.dynamo.cr.editor 4 75 2017-01-17 14:56:07.231
!MESSAGE Build failed: Java heap space
!STACK 0
com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more

!ENTRY com.dynamo.cr.editor.handlers.AbstractBundleHandler 4 0 2017-01-17 14:56:07.344
!MESSAGE Unable to bundle application
!STACK 1
org.eclipse.core.internal.resources.ResourceException: Errors occurred during the build.
at org.eclipse.core.internal.resources.Project$1.run(Project.java:620)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Contains: Errors running builder ‘Content Builder’ on project ‘Pomenia’.
org.eclipse.core.runtime.CoreException: Build failed: Java heap space
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:177)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
… 13 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more
Contains: Build failed: Java heap space
com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more
!SUBENTRY 1 org.eclipse.core.resources 4 566 2017-01-17 14:56:07.345
!MESSAGE Errors occurred during the build.
!SUBENTRY 2 com.dynamo.cr.editor 4 75 2017-01-17 14:56:07.345
!MESSAGE Errors running builder ‘Content Builder’ on project ‘Pomenia’.
!STACK 1
org.eclipse.core.runtime.CoreException: Build failed: Java heap space
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:177)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
… 13 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more
!SUBENTRY 3 com.dynamo.cr.editor 4 75 2017-01-17 14:56:07.364
!MESSAGE Build failed: Java heap space
!STACK 0
com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more
!SUBENTRY 2 com.dynamo.cr.editor 4 75 2017-01-17 14:56:07.369
!MESSAGE Build failed: Java heap space
!STACK 0
com.dynamo.bob.CompileExceptionError: Java heap space
at com.dynamo.bob.Project.build(Project.java:268)
at com.dynamo.cr.editor.builders.ContentBuilder.buildLocal(ContentBuilder.java:135)
at com.dynamo.cr.editor.builders.ContentBuilder.build(ContentBuilder.java:83)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.buildProject(AbstractBundleHandler.java:63)
at com.dynamo.cr.editor.handlers.AbstractBundleHandler$BundleRunnable.run(AbstractBundleHandler.java:72)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3230)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at com.dynamo.bob.bundle.AndroidBundler.bundleApplication(AndroidBundler.java:286)
at com.dynamo.bob.Project.bundle(Project.java:408)
at com.dynamo.bob.Project.doBuild(Project.java:500)
at com.dynamo.bob.Project.build(Project.java:263)
… 14 more

I think you should be able to increase the heap size of the editor by modifying Defold.ini (located inside Defold.app on Mac and in the application folder on Windows). -Xmx is the value you’re looking for I think.

2 Likes

@britzl Thanks. It seems that I managed to build an Android apk by increasing the heap size. Scary 400MB apk, but it works.

3 Likes

You should look into texture profiles and use texture compression to reduce the APK size.

3 Likes

We tried to do that earlier, but build failed with that also. Maybe we try again now with bigger heap size. :slight_smile:

1 Like

With mac I am able to bring heap size to 9600M that was enough to use webp compression for images. I or Defold is doing something wrong with it, because I ended up with 1,3GB apk with that option. When I have little more time, I will test more with it.

With Windows machine after growing the heap size to 2400M, Defold did not open anymore. That might be device dependant issue. I will try that when I am back home with my own device.

I am back at the same problem with Editor 2. Editor 2 seems to have different configuration file and format than Editor 1. Is there a way to increase heap size for Editor 2?

1 Like

Not sure. @mats.gisselson, @Ragnar_Dahlen, @Erik_Angelin?

1 Like

Well, I guess you could experiment with jvm flags: https://stackoverflow.com/questions/6452765/how-to-increase-heap-size-of-jvm
The flags should go in the config file under vmargs. Note however that we overwrite config when updating, so you will have to redo your changes.

1 Like

Also, if you just want to build (not bundle) there is a preference for enabling/disabling texture compression, that will reduce memory usage.

1 Like

Thanks. I will experiment jvm flags when I have good spare time for it. I have now been using Editor 1 to make the build succesfully.