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?
The native executable for our application will contain the application code, required libraries, Java APIs, and a reduced version of a VM. The smaller VM base improves the startup time of the application and produces a minimal disk footprint.
A program ready to run in the native language of a particular CPU family. The term implies that there are no additional conversion steps necessary in order for the instructions in the program to be executed. Contrast with interpreted language.
Quarkus provides extensions for building (and pushing) container images. Currently, it supports: Jib. Docker.
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.
@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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With