◀Table of Contents
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 HelloWorld
class:
================================================================================
GraalVM Native Image: Generating 'helloworld' (executable)...
================================================================================
[1/7] Initializing... (2.5s @ 0.21GB)
Version info: 'GraalVM dev Java 11 CE'
C compiler: gcc (linux, x86_64, 9.3.0)
Garbage collector: Serial GC
[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:
607.28KB java.util 862.66KB byte[] for general heap data
288.63KB java.lang 834.02KB byte[] for code metadata
223.34KB java.util.regex 723.00KB java.lang.String
220.45KB java.text 534.05KB java.lang.Class
194.21KB com.oracle.svm.jni 457.63KB byte[] for java.lang.String
153.69KB java.util.concurrent 363.75KB java.util.HashMap$Node
118.78KB java.math 192.70KB java.util.HashMap$Node[]
99.00KB com.oracle.svm.core.reflect 140.03KB java.lang.String[]
98.21KB sun.text.normalizer 139.04KB char[]
89.95KB c.oracle.svm.core.genscavenge 132.78KB c.o.s.c.h.DynamicHubCompanion
... 112 additional packages ... 734 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
Initializing
In this stage, the Native Image build process is set up and Features
are initialized.
Native Image Kind
By default, Native Image generates executables but it can also generate shared libraries and static executables.
Version Info
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.
C Compiler
The C compiler executable, vendor, target architecture, and version info used by the Native Image build process.
Garbage Collector
The garbage collector used within the generated image:
- The Serial GC is the default GC and optimized for low memory footprint and small Java heap sizes.
- The G1 GC (only available with GraalVM Enterprise Edition) is a multi-threaded GC that is optimized to reduce stop-the-world pauses and therefore improve latency while achieving high throughput.
- The Epsilon GC does not do any garbage collection and is designed for very short-running applications that only allocate a small amount of memory.
For more information see the docs on Memory Management at Image Run Time.
User-provided Features
All 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.
Reachable Classes, Fields, and Methods
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.
Reflection Registrations
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 reflection metadata).
JNI Access Registrations
The number of classes, fields, and methods that are registered for JNI access.
Runtime Compiled Methods
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).
Code Area
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.
Image Heap
The image heap contains reachable objects such as static application data, metadata, and byte[]
for different purposes.
General Heap Data Stored in byte[]
The total size of all byte[]
objects that are neither used for java.lang.String
, nor code metadata, nor reflection metadata, nor graph encodings.
Therefore, this can also include byte[]
objects from application code.
Code Metadata Stored in byte[]
The total size of all byte[]
objects used for metadata for the code area.
Therefore, reducing the number of reachable methods also reduces the size of this metadata.
Reflection Metadata Stored in byte[]
The total size of all byte[]
objects used for reflection metadata, including class, field, method and constructor data.
To reduce the amount of reflection metadata, reduce the number of elements registered for reflection.
Graph Encodings Stored in byte[]
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.
Debug Info
The total size of generated debug information (if enabled).
Other Data
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
Garbage Collections
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 RSS
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.
CPU load
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
Run 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).