- Latest (GraalVM for JDK 21)
- Dev Build
- GraalVM for JDK 21
- GraalVM for JDK 20
- GraalVM for JDK 17
- GraalVM 22.3
- GraalVM 22.2
- GraalVM 22.1
- GraalVM 22.0
- GraalVM 21.3
- Native Image
- Build Configuration
- Tracing Agent
- Native Image Compatibility and Optimization Guide
- Class Initialization in Native Image
- Static Native Images
- Native Image Options
- Native Image Hosted and Runtime Options
- Native Image C API
- Implementing Native Methods in Java with Native Image
- LLVM Backend for Native Image
- Debug Info Feature
- Points-to Analysis Reports
- Using System Properties in Native Images
- Profile-Guided Optimizations
- Memory Management at Image Run Time
- Generating Heap Dumps from Native Images
- JDK Flight Recorder with Native Image
- JCA Security Services on Native Image
- Dynamic Proxy on Native Image
- Java Native Interface (JNI) on Native Image
- Reflection on Native Image
- Accessing Resources in Native Images
- Logging on Native Image
- URL Protocols on Native Image
- Native Image ARM64 Support
- GraalVM Updater
- Languages References
- Embedding Reference
- Polyglot Programming
Native Image Build Output
This page provides documentation for the build output of GraalVM Native Image.
Below is the example output when building a native image of the
================================================================================ GraalVM Native Image: Generating 'helloworld'... ================================================================================ [1/7] Initializing... (2.5s @ 0.21GB) Version info: 'GraalVM dev Java 11 CE' [2/7] Performing analysis... [*******] (5.6s @ 0.46GB) 2,565 (82.61%) of 3,105 classes reachable 3,216 (60.42%) of 5,323 fields reachable 11,652 (72.44%) of 16,086 methods reachable 27 classes, 0 fields, and 135 methods registered for reflection 57 classes, 59 fields, and 51 methods registered for JNI access [3/7] Building universe... (0.5s @ 0.61GB) [4/7] Parsing methods... [*] (0.5s @ 0.86GB) [5/7] Inlining methods... [****] (0.5s @ 0.73GB) [6/7] Compiling methods... [**] (3.7s @ 2.38GB) [7/7] Creating image... (2.1s @ 1.04GB) 3.69MB (27.19%) for code area: 6,955 compilation units 5.86MB (43.18%) for image heap: 1,545 classes and 80,528 objects 3.05MB (22.46%) for debug info generated in 1.0s 997.25KB ( 7.18%) for other data 13.57MB in total -------------------------------------------------------------------------------- Top 10 packages in code area: Top 10 object types in image heap: 606.23KB java.util 1.64MB byte for general heap data 282.34KB java.lang 715.56KB java.lang.String 222.47KB java.util.regex 549.46KB java.lang.Class 219.55KB java.text 451.79KB byte for java.lang.String 193.17KB com.oracle.svm.jni 363.23KB java.util.HashMap$Node 149.80KB java.util.concurrent 192.00KB java.util.HashMap$Node 118.07KB java.math 139.83KB java.lang.String 103.60KB com.oracle.svm.core.reflect 139.04KB char 97.83KB sun.text.normalizer 130.59KB j.u.c.ConcurrentHashMap$Node 88.78KB c.oracle.svm.core.genscavenge 103.92KB s.u.l.LocaleObjec~e$CacheEntry ... 111 additional packages ... 723 additional object types (use GraalVM Dashboard to see all) -------------------------------------------------------------------------------- 0.9s (5.6% of total time) in 17 GCs | Peak RSS: 3.22GB | CPU load: 10.87 -------------------------------------------------------------------------------- Produced artifacts: /home/janedoe/helloworld/helloworld (executable) /home/janedoe/helloworld/sources (debug_info) /home/janedoe/helloworld/helloworld (debug_info) /home/janedoe/helloworld/helloworld.build_artifacts.txt ================================================================================ Finished generating 'helloworld' in 16.2s.
Build Stages #
In this stage, the Native Image build process is set up and
Features are initialized.
The version info of the Native Image process.
This string is also used for the
java.vm.version property within the generated image.
Please report this version info when you file issues.
Features that are provided by the user or implicitly registered for the user, for example, by a framework.
GraalVM Native Image deploys a number of internal features, which are excluded from this list.
Performing Analysis #
In this stage, a points-to analysis is performed. The progress indicator visualizes the number of analysis iterations. A large number of iterations can indicate problems in the analysis likely caused by misconfiguration or a misbehaving feature.
The number of classes, fields, and methods that are reachable versus the total number of classes and methods loaded as part of the build process. A significantly larger number of loaded classes that are not reachable can indicate a configuration problem. To reduce overhead, please ensure that the classpath only contains entries that are needed for building the application.
The number of classes, fields, and methods that are registered for reflection. Large numbers can cause significant reflection overheads, slow down the build process, and increase the size of the native image (see method metadata).
The number of classes, fields, and methods that are registered for JNI access.
The number of methods marked for runtime compilation. This number is only shown if runtime compilation is built into the image, for example, when building a Truffle language. Runtime compiled methods account for graph encodings in the image heap.
Building Universe #
In this stage, a universe with all classes, fields, and methods is built, which is then used to create the native image.
Parsing Methods #
In this stage, the Graal compiler parses all reachable methods. The progress indicator is printed periodically at an increasing interval.
Inlining Methods #
In this stage, trivial method inlining is performed. The progress indicator visualizes the number of inlining iterations.
Compiling Methods #
In this stage, the Graal compiler compiles all reachable methods to machine code. The progress indicator is printed periodically at an increasing interval.
Creating Image #
In this stage, the native image is created and written to disk. Debug info is also generated as part of this stage (if requested).
The code area contains machine code produced by the Graal compiler for all reachable methods. Therefore, reducing the number of reachable methods also reduces the size of the code area.
The image heap contains reachable objects such as static data, classes initialized at run-time, and
byte for different purposes.
The total size of all
byte objects used for graph encodings.
These encodings are a result of runtime compiled methods.
Therefore, reducing the number of such methods also reduces the size of corresponding graph encodings.
The total size of all
byte objects used for method metadata, a type of reflection metadata.
To reduce the amount of method metadata, reduce the number of classes registered for reflection.
The total size of generated debug information (if enabled).
The amount of data in the image that is neither in the code area, nor in the image heap, nor debug info. This data typically contains internal information for Native Image and should not be dominating.
Resource Usage Statistics #
The total time spent in all garbage collectors, total GC time divided by the total process time in percent, and the total number of garbage collections. A large number of collections or time spent in collectors usually indicates that the system is under memory pressure. Increase the amount of available memory to reduce the time to build the image.
Peak resident set size as reported by the operating system. This value indicates the maximum amount of memory consumed by the build process. If the GC statistics do not show any problems, the amount of available memory of the system can be reduced to a value closer to the peak RSS.
The CPU time used by the process divided by the total process time. Increase the number of CPU threads to reduce the time to build the image.
Build Output Options #
native-image --expert-options-all | grep "BuildOutput" to see all build output options:
-H:±BuildOutputBreakdowns Show code and heap breakdowns as part of the build output. Default: + (enabled). -H:±BuildOutputColorful Colorize build output. Default: + (enabled). -H:±BuildOutputGCWarnings Print GC warnings as part of build output. Default: + (enabled). -H:±BuildOutputLinks Show links in build output. Default: + (enabled). -H:±BuildOutputPrefix Prefix build output with '<pid>:<image name>'. Default: - (disabled). -H:±BuildOutputProgress Report progress in build output. Default: + (enabled). -H:±BuildOutputUseNewStyle Use new build output style. Default: + (enabled).