Ad

Wired Out Of Memory: Java Heap Space Error With Ffmpeg Library

Well this is the error I get:

Out of memory: Java heap space.
Please assign more memory to Gradle in the project's gradle.properties file.
For example, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB:
<em>org.gradle.jvmargs=-Xmx1024m</em>

and it is because of:

implementation 'nl.bravobit:android-ffmpeg:1.1.7'

when I remove that the error gets gone.Well the error is saying increase the heap size to 1024MB and I did increase it to 10GB it's not still working.That's what is wired.

org.gradle.jvmargs=-Xmx10000m

still getting the same error.also tried this:

<application
        android:largeHeap="true">

still no chance.Please do not suggest to use an alternative library because I can't.

Ad

Answer

In gradle 5 they vastly reduced the default memory requirements.

The command line client now starts with 64MB of heap instead of 1GB. This may affect builds running directly inside the client VM using --no-daemon mode. We discourage the use of --no-daemon, but if you must use it, you can increase the available memory using the GRADLE_OPTS environment variable.

The Gradle daemon now starts with 512MB of heap instead of 1GB. Large projects may have to increase this setting using the org.gradle.jvmargs property.

All workers, including compilers and test executors, now start with 512MB of heap. The previous default was 1/4th of physical memory. Large projects may have to increase this setting on the relevant tasks, e.g. JavaCompile or Test.

Increase Client Memory

GRADLE_OPTS=-Xmx1g ./gradlew build

Increase Daemon Memory

./gradlew -D org.gradle.jvmargs=-Xmx1g

Update:

For additional clarification, gradle uses a client VM, a daemon VM, worker VMs (when run in parallel), and additional VMs for certain tasks.

The client VM can be customized using the GRADLE_OPTS environment variable.

The daemon VM can be customized using the org.gradle.jvmargs property.

The worker VMs are forked from the daemon VM so will use the same settings.

The per task VMs can be customized through the task. For example

tasks.withType(JavaCompile) { options.compilerArgs += ['-Xdoclint:none', '-Xlint:none', '-nowarn'] }

According to the gradle documentation on Client VM usage:

The client VM only handles command line input/output, so it is rare that one would need to change its VM options.

Ad
source: stackoverflow.com
Ad