0

I was trying to build with bubblewrap and I couldn't find an answer anywhere. it says that outofmemory error

cli ERROR Command failed: gradlew.bat bundleRelease --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
unable to create native thread: possibly out of memory or process/resource limits reached

* Exception is:
java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

it says it's out of memory and to allocate more I need to run the java command my self which I can't is there anything I can do here?

1 Answers1

3

As described in this issue: https://github.com/GoogleChromeLabs/bubblewrap/issues/611

Unfortunately, this is an issue with the JVM on Windows, and there isn't much that can be done in Bubblewrap.

It seems the JVM requires contiguous memory addresses when allocating memory. Even though the machine may have enough memory, and enough memory free, the JVM can fail to allocate if the memory is fragmented. There are more details in this StackOverflow question: Java maximum memory on Windows XP

The -Xmx1536 parameter is the default used by Android Studio when creating Android projects. Removing -Xmx1536 worked in this case, but is unlikely to work in all cases for 2 reasons:

If Gradle actually needs that amount of memory, it will still be unable to allocate it and the build will fail (at a later time). It may still be impossible to allocate smaller chunks of memory.

Rebooting Windows is a solution known to help in these cases too.

andreban
  • 4,621
  • 1
  • 20
  • 49