Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quarkus native executable build: high memory consumption

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?

like image 950
Ben Avatar asked Jul 23 '19 14:07

Ben


People also ask

What is Quarkus native executable?

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.

What is a native executable?

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.

Does Quarkus use Docker?

Quarkus provides extensions for building (and pushing) container images. Currently, it supports: Jib. Docker.


2 Answers

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.

like image 107
Ben Avatar answered Oct 02 '22 15:10

Ben


@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>
like image 37
Panciz Avatar answered Oct 02 '22 16:10

Panciz