Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit code 137 even with -Dquarkus.native.native-image-xmx=4G when building native app #26196

Closed
tigerinus opened this issue Jun 17, 2022 · 8 comments
Labels
area/mandrel kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@tigerinus
Copy link

tigerinus commented Jun 17, 2022

Describe the bug

Tried to build native app with

$ gradle build -Dquarkus.package.type=native -Dquarkus.native.native-image-xmx=4G

But it always complains not enough memory

Noticed that the memory usage does not actually change much, even with quarkus.native.native-image-xmx=4G, which indicates that the build process might not see this flag at all.

Expected behavior

It builds fine.

Actual behavior

========================================================================================================================
GraalVM Native Image: Generating 'casaos-event-system-0.0.1-runner' (executable)...
========================================================================================================================
[1/7] Initializing...                                                                                   (25.5s @ 0.21GB)
 Version info: 'GraalVM 22.1.0.0-Final Java 17 Mandrel Distribution'
 C compiler: gcc (linux, x86_64, 11.2.0)
 Garbage collector: Serial GC
 3 user-provided feature(s)
  - io.quarkus.runner.AutoFeature
  - io.quarkus.runtime.graal.DisableLoggingAutoFeature
  - io.quarkus.runtime.graal.ResourcesFeature
[2/7] Performing analysis...  [**********]                                                             (159.9s @ 1.31GB)
  13,082 (91.14%) of 14,353 classes reachable
  18,598 (61.79%) of 30,101 fields reachable
  66,566 (59.03%) of 112,774 methods reachable
     472 classes,   230 fields, and 2,291 methods registered for reflection
      64 classes,    75 fields, and    55 methods registered for JNI access
[3/7] Building universe...                                                                              (14.3s @ 1.82GB)
Error: Image build request failed with exit status 137
> Task :quarkusBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':quarkusBuild'.
> io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: io.quarkus.deployment.pkg.steps.NativeImageBuildStep$ImageGenerationFailureException: Image generation failed. Exit code was 137 which indicates an out of memory error. Consider increasing the Xmx value for native image generation by setting the "quarkus.native.native-image-xmx" property
        at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:395)
        at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:240)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:925)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4m 10s
6 actionable tasks: 1 executed, 5 up-to-date

How to Reproduce?

Create a project that uses following dependencies

dependencies {
    implementation 'io.quarkus:quarkus-jackson'
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'io.quarkus:quarkus-smallrye-graphql'
    implementation 'io.quarkus:quarkus-arc'
    testImplementation 'io.quarkus:quarkus-junit5'
}

Output of uname -a or ver

Linux zb-red 5.15.0-37-generic #39-Ubuntu SMP Wed Jun 1 19:16:45 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.3" 2022-04-19 OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7) OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.4.2

Additional information

No response

@tigerinus tigerinus added the kind/bug Something isn't working label Jun 17, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 17, 2022

/cc @Karm, @galderz, @zakkak

@zakkak
Copy link
Contributor

zakkak commented Jun 17, 2022

Hello @tigerinus , how are you building the native-image? Using a container or on the bare metal? How much physical memory does the system have? Did you try increasing the max heap size as suggested by the error log?

@tigerinus
Copy link
Author

tigerinus commented Jun 17, 2022

Hello @tigerinus , how are you building the native-image? Using a container or on the bare metal? How much physical memory does the system have? Did you try increasing the max heap size as suggested by the error log?

I simply did

$ gradle build -Dquarkus.package.type=native -Dquarkus.native.native-image-xmx=4G

Not sure if it's bare metal or container build, but i did include the heap increase setting as you can see.

My laptop is 16GB ram

@geoand
Copy link
Contributor

geoand commented Jun 17, 2022

4GB of memory is likely not enough. Did you try -Dquarkus.native.native-image-xmx=6G?

@tigerinus
Copy link
Author

4GB of memory is likely not enough. Did you try -Dquarkus.native.native-image-xmx=6G?

I could try again, but even with quarkus.native.native-image-xmx=4G the build process barely used less than half of 4G.. I was watching the memory usage.

@geoand
Copy link
Contributor

geoand commented Jun 17, 2022

Java memory management is a very complex, so it's not always easy to determine what the actual memory usage is.

Please go ahead and try -Dquarkus.native.native-image-xmx=6G

@tigerinus
Copy link
Author

Java memory management is a very complex, so it's not always easy to determine what the actual memory usage is.

Please go ahead and try -Dquarkus.native.native-image-xmx=6G

OK - 6G works.

Is memory usage proportional to the complexity of the project?

My worry is this is such a simple project - my first project to get familiar with Quarkus. It only does simple in-memory CRUD via GraphQL. Wonder how much memory does it need if it's a more complicated real-world app.

@zakkak
Copy link
Contributor

zakkak commented Jun 17, 2022

Is memory usage proportional to the complexity of the project?

Yes and no :)

In general the more code you bring in the more memory it requires to process it and the longer it takes. Note, however, that even if a project appears simple if it's bringing a lot of dependencies it will require significantly more memory and time to compile.

@zakkak zakkak closed this as completed Jun 17, 2022
@geoand geoand added the triage/invalid This doesn't seem right label Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mandrel kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants