Search code examples
quarkusdocker-multi-stage-build

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?


Solution

  • 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.