android - 连线内存不足 : Java heap space error with ffmpeg library

标签 android gradle ffmpeg out-of-memory heap-memory

那么这是我得到的错误:

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>

这是因为:
implementation 'nl.bravobit:android-ffmpeg:1.1.7'

当我删除错误消失了。嗯,错误是说将堆大小增加到 1024MB,我确实将它增加到 10GB,它仍然无法工作。这就是有线的。
org.gradle.jvmargs=-Xmx10000m

仍然得到同样的错误。也试过这个:
<application
        android:largeHeap="true">

仍然没有机会。请不要建议使用替代库,因为我不能。

最佳答案

在 gradle 5 中,他们大大减少了 default memory要求。

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.



增加客户端内存
GRADLE_OPTS=-Xmx1g ./gradlew build

增加守护进程内存
./gradlew -D org.gradle.jvmargs=-Xmx1g

更新:

为了进一步说明,gradle 使用客户端 VM、守护进程 VM、工作 VM(并行运行时)以及用于某些任务的附加 VM。

可以使用 GRADLE_OPTS 自定义客户端 VM环境变量。

可以使用 org.gradle.jvmargs 自定义守护程序 VM属性(property)。

工作虚拟机是从守护程序虚拟机派生的,因此将使用相同的设置。

可以通过任务自定义每个任务的虚拟机。对于example

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



根据有关客户端 VM 使用的 gradle 文档:

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

关于android - 连线内存不足 : Java heap space error with ffmpeg library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56271816/

相关文章:

android - 将图像包装到android中的cardView

android - LocalStorage 与 Phonegap 不持久

gradle - 在Mac上对Gradle构建进行Docker化

android - 无限 Gradle 构建运行 Java 8

android - Flutter android构建失败

Android:获取最新 Intent

java - 如何抑制初始化警告

ffmpeg - 如何在 ffmpeg 中设置 ReFrames?

command-line - ffmpeg:使用更多选项执行

c# - 在 C# 中使用 ffmpeg.exe 将 MPG 转换为 AVI