Reputation: 457
I'm building a Quarkus native executable with a multi-stage Docker build as described in Quarkus - Building a Native Executable
My project just includes the Hello World
-Example with some added ORM-functionality (so not really a lot of dependencies). The build works fine, but my problem is, that it consumes a lot of memory during build time. That means up to 6 GiB
. Build time is also very long in my opinion (~4-6 minutes in total).
The problem starts when I'm building on our CI/CD-infrastructure. We don't have that much memory there and so the build fails with Error: Image build request failed with exit status 137
.
Am I doing something wrong or is this just the normal behaviour? Is there a possibility to reduce at least the memory consumption?
Upvotes: 7
Views: 6991
Reputation: 353
Now, you can limit memory usage from Quarkus:
In your src/main/resources/application.properties file, just set:
quarkus.native.native-image-xmx=2G
Or just pass this option to maven:
mvn package -Dnative -Dquarkus.native.native-image-xmx=2G
Upvotes: 4
Reputation: 41
With camel quarkus example using maven, I configured as follows to make it work:
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.additional-build-args>-J-Xmx5G</quarkus.native.additional-build-args>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Using the option <quarkus.native.additional-build-args>-J-Xmx5G</quarkus.native.additional-build-args>
Upvotes: 1
Reputation: 21
If you are using gradle, edit the build.gradle
like this:
.
.
.
compileJava {
options.compilerArgs << '-parameters'
}
buildNative {
additionalBuildArgs = [
'-J-Xmx2G'
]
}
So you can limit the memory usage when building with gradle.
Upvotes: 2
Reputation: 2234
@ben answer is correct but maybe it is useful to be more precise. You have to edit the pom.xml
in the getting-started
dir and edit the native
profile
and adding <additionalBuildArgs>-J-Xmx2G</additionalBuildArgs>
like this:
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
<additionalBuildArgs>-J-Xmx2G</additionalBuildArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
...
</plugin>
</plugins>
</build>
</profile>
Upvotes: 5
Reputation: 457
Thanks to Ken and Luca Burgazzoli! So, it is normal for GraalVM to use >4GiB of RAM and to take more than 3 minutes.
One can limit memory consumption by specifiying -J-Xmx2G
as an additionalBuildArgs
-param for the quarkus-maven-plugin
. But this may increase build time.
Upvotes: 7