Open cnico opened 2 weeks ago
Hi @cnico,
Thank you for sharing this with us. I tested on my end and I confirm the issue you're facing. We will take a look into this and I'll keep you updated
Hi @cnico,
Could you please try to test while using this option -H:ThrowMissingRegistrationErrors=
to your native image build command and share your findings with me?
Here's an Example Command:
native-image -H:ThrowMissingRegistrationErrors= -jar your-app.jar
Hi @selhagani, I have added this option to the build and I see it is correctly taken into account by the maven build logs. The native executable is correctly generated without error. When I start the exe, it works without error or warning on the console and I still can not attach the process in visualvm. I added it to the github project that helps reproducing the problem in case you want to have a look at it : https://github.com/cnico/native-image-maven-demo
Could you please share with me the logs now that you added that option for the newly built native image? thank you!
The logs at build time are :
...
========================================================================================================================
GraalVM Native Image: Generating 'demo-native-image-maven' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing... (40,4s @ 0,18GB)
Java version: 22.0.2+9, vendor version: GraalVM CE 22.0.2+9.1
Graal compiler: optimization level: 2, target machine: x86-64-v3
C compiler: cl.exe (microsoft, x64, 19.38.33135)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s):
- com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
1 experimental option(s) unlocked:
- '-H:ThrowMissingRegistrationErrors': This can happen on reflection and serialization queries, and resource access. (origin(s): command line)
------------------------------------------------------------------------------------------------------------------------
Build resources:
- 20,88GB of memory (52,6% of 39,68GB system memory, determined at start)
- 12 thread(s) (100,0% of 12 available processor(s), determined at start)
# Printing compilation-target information to: D:\platform_java21\workspace\native-image-maven-demo\target\reports\target_info_20240828_135049.txt
# Printing native-library information to: D:\platform_java21\workspace\native-image-maven-demo\target\reports\native_library_info_20240828_135057.txt
[2/8] Performing analysis... [*****] (8,0s @ 0,28GB)
3?177 reachable types (72,2% of 4?400 total)
3?686 reachable fields (42,8% of 8?615 total)
14?815 reachable methods (44,2% of 33?534 total)
1?058 types, 53 fields, and 545 methods registered for reflection
61 types, 51 fields, and 52 methods registered for JNI access
1 native library: version
[3/8] Building universe... (1,4s @ 0,29GB)
[4/8] Parsing methods... [*] (0,8s @ 0,31GB)
[5/8] Inlining methods... [***] (0,7s @ 0,33GB)
[6/8] Compiling methods... [***] (8,2s @ 0,30GB)
[7/8] Laying out methods... [*] (1,0s @ 0,35GB)
[8/8] Creating image... [*] (1,3s @ 0,43GB)
5,13MB (40,41%) for code area: 8?401 compilation units
7,41MB (58,30%) for image heap: 90?255 objects and 75 resources
167,95kB ( 1,29%) for other data
12,70MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
3,77MB java.base 1,52MB byte[] for code metadata
983,86kB svm.jar (Native Image) 1,21MB byte[] for java.lang.String
114,75kB java.logging 910,38kB java.lang.String
65,55kB org.graalvm.nativeimage.base 753,29kB java.lang.Class
45,84kB jdk.proxy3 383,88kB heap alignment
44,42kB jdk.proxy1 347,78kB byte[] for general heap data
27,00kB jdk.internal.vm.ci 273,02kB com.oracle.svm.core.hub.DynamicHubCompanion
22,68kB org.graalvm.collections 244,31kB java.util.HashMap$Node
11,42kB jdk.proxy2 196,05kB java.lang.Object[]
8,18kB jdk.graal.compiler 180,16kB java.lang.String[]
4,68kB for 3 more packages 1,47MB for 883 more object types
------------------------------------------------------------------------------------------------------------------------
Recommendations:
HEAP: Set max heap for improved and more predictable memory usage.
CPU: Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
1,3s (2,0% of total time) in 176 GCs | Peak RSS: 0,82GB | CPU load: 3,40
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
D:\platform_java21\workspace\native-image-maven-demo\target\demo-native-image-maven.exe (executable)
========================================================================================================================
Finished generating 'demo-native-image-maven' in 1m 2s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
And there is no log à runtime for the exe : I have just the System.out.print of my Java main :
D:\platform_java21\workspace\native-image-maven-demo>target\demo-native-image-maven.exe
Starting to compute prime numbers :)
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
...
and so on to the end of the program.
Hi, Do you have any news on this ticket?
Describe the issue We use native image to build windows native executables and it works very well. As the project gets bigger we investigate on monitoring of the native image to detect memory leak, cpu usage, etc. So we investigated on the option --enable-monitoring=all (same result with jvmstat or heapdump). The native image build is OK but visualvm does never find the native image processus. I did a simple project to reproduce the problem : https://github.com/cnico/native-image-maven-demo It builds and runs on linux with the correct expectation of visualvm finding the processus. But on windows it finds no processus to attach as native image. It works great for the java -jar execution of course.
Steps to reproduce the issue
Describe GraalVM and your environment:
More details The generated native-image args file seems correct : @target\tmp\native-image-6483500328482094922.args :
Here are the logs of the maven execution of the native image with --native-image-info and --verbose options :