You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference-manual/native-image/BuildOptions.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ The following options are supported across both GraalVM Community and Enterprise
28
28
*`--enable-https`: enable HTTPS support in a native executable
29
29
*`--enable-preview`: allow classes to depend on preview features of this release
30
30
*`--enable-url-protocols`: list comma-separated URL protocols to enable
31
+
*`--enable-monitoring`: enable monitoring features that allow the VM to be inspected at run time. Comma-separated list can contain 'heapdump', 'jfr', 'jvmstat', or 'all'. For example: `--enable-monitoring=heapdump,jvmstat`.
31
32
*`--features`: a comma-separated list of fully qualified [Feature implementation classes](https://www.graalvm.org/sdk/javadoc/index.html?org/graalvm/nativeimage/hosted/Feature.html)
32
33
*`--force-fallback`: force building of a fallback native executable
33
34
*`--gc=<value>`: select Native Image garbage collector implementation. Allowed options for `<value>` are: `G1` for G1 garbage collector (**GraalVM Enterprise only**); `epsilon` for Epsilon garbage collector; `serial` for Serial garbage collector (default).
Copy file name to clipboardExpand all lines: docs/reference-manual/native-image/JFR.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,9 @@ To record JFR events when running a native executable, JFR support and JFR recor
17
17
18
18
To build a native executable with the JFR events support, you first need to include JFR at build time, then enable the system, start a recording, and configure logging at native executable run time.
19
19
20
-
To build a native executable with JFR, use the `-H:+AllowVMInspection` flag:
20
+
To build a native executable with JFR, use the `--enable-monitoring=jfr` flag:
Copy file name to clipboardExpand all lines: docs/reference-manual/native-image/guides/build-and-run-native-executable-with-jfr.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,12 @@ GraalVM Native Image supports JFR events and users can use [`jdk.jfr.Event`](htt
12
12
13
13
To record JFR events when running a native executable, JFR support and JFR recording must be enabled, and this guide covers how to do that.
14
14
15
-
> Note: JFR events recording is not supported on GraalVM distribution for Windows. JFR is only supported with native executables built on GraalVM JDK 11.
15
+
> Note: JFR events recording is not supported on GraalVM JDK for Windows. JFR is only supported with native executables built on GraalVM JDK 11.
16
16
17
17
## Enable JFR Support and Record Events at Run Time
18
18
19
-
To build a native executable with the JFR events support, you first need to include JFR at build time, then enable the system, start a recording, and configure logging at native executable run time.
20
-
The following options are supported:
21
-
*`-H:+AllowVMInspection`: enable the VM inspection
22
-
*`-XX:+FlightRecorder`: use to enable JFR
19
+
To build a native executable with the JFR events support, you first need to add the `--enable-monitoring=jfr` option when invoking the `native-image` tool. Then enable the system, start a recording, and configure logging at native executable run time:
20
+
*`-XX:+FlightRecorder`: use to enable JFR at run time
23
21
*`-XX:StartFlightRecording`: use to start a recording on application's startup
24
22
*`-XX:FlightRecorderLogging`: use to configure the log output for the JFR system
25
23
@@ -61,9 +59,9 @@ Follow the steps below to practice building a native executable with JFR support
61
59
62
60
3. Build a native executable with the VM inspection enabled:
You can create a heap dump of a running executable to monitor its execution. Just like any other Java heap dump, it can be opened with the [VisualVM](../../../tools/visualvm.md) tool.
11
11
12
-
To enable heap dump support, native executables must be built with the `-H:+AllowVMInspection` option. Heap dumps can then be created in three different ways:
12
+
To enable heap dump support, native executables must be built with the `--enable-monitoring=heapdump` option. Heap dumps can then be created in three different ways:
13
13
14
-
1. Dump the initial heap of a native executable using the `-XX:+DumpHeapAndExit` command-line option.
15
-
2. Create heap dumps sending `USR1` (other supported signals are `QUIT/BREAK` for stack dumps and `USR2` to dump runtime compilation information).
16
-
3. Create a heap dumps programmatically through the [`org.graalvm.nativeimage.VMRuntime#dumpHeap`](https://github.com/oracle/graal/blob/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspection.java) API.
14
+
1. Create heap dumps with VisualVM.
15
+
2. Dump the initial heap of a native executable using the `-XX:+DumpHeapAndExit` command-line option.
16
+
3. Create heap dumps sending a `SIGUSR1` signal at run time.
17
+
4. Create heap dumps programmatically using the [`org.graalvm.nativeimage.VMRuntime#dumpHeap`](https://github.com/oracle/graal/blob/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspection.java) API.
17
18
18
19
All three approaches are described below.
19
20
20
21
>Note: Creating heap dumps is not available on the Microsoft Windows platform.
21
22
23
+
## Create Heap Dumps with VisualVM
24
+
25
+
A convenient way to create heap dumps is to use [VisualVM](../../../tools/visualvm.md).
26
+
For this, you need to add `jvmstat` to the `--enable-monitoring` option (for example, `--enable-monitoring=heapdump,jvmstat`).
27
+
This will allow VisualVM to pick up and list running Native Image processes.
28
+
You can then request heap dumps in the same way you can request them when your application runs on the JVM (for example, right-click on the process, then select "Heap Dump").
29
+
22
30
## Dump the Initial Heap of a Native Executable
23
31
24
32
Use the `-XX:+DumpHeapAndExit` command-line option to dump the initial heap of a native executable.
25
33
This can be useful to identify which objects the Native Image build process allocated to the executable's heap.
26
34
For a HelloWorld example, use the option as follows:
## Create Heap Dumps with SIGUSR1 (Linux/macOS only)
35
43
36
44
The following example is a simple multi-threaded Java application that runs for 60 seconds.
37
-
This provides you with enough time to send it a `USR1` signal. The application will handle the signal and create a heap dump in the application's working directory. The heap dump will contain the `Collection` of `Person`s referenced by the static variable `CROWD`.
45
+
This provides you with enough time to send it a `SIGUSR1` signal. The application will handle the signal and create a heap dump in the application's working directory. The heap dump will contain the `Collection` of `Person`s referenced by the static variable `CROWD`.
38
46
39
-
Follow these steps to build a native executable that will produce a heap dump when it receives a `USR1` signal.
47
+
Follow these steps to build a native executable that will produce a heap dump when it receives a `SIGUSR1` signal.
40
48
41
49
1. Save the following code in a file named _SVMHeapDump.java_:
42
50
```java
@@ -122,11 +130,11 @@ Follow these steps to build a native executable that will produce a heap dump wh
122
130
```shell
123
131
$JAVA_HOME/bin/javac SVMHeapDump.java
124
132
```
125
-
Build a native executable using the `-H:+AllowVMInspection` command-line option.
126
-
(This causes the resulting native executable to produce a heap dump when it receives a `USR1` signal.)
133
+
Build a native executable using the `--enable-monitoring=heapdump` command-line option.
134
+
(This causes the resulting native executable to produce a heap dump when it receives a `SIGUSR1` signal.)
Copy file name to clipboardExpand all lines: docs/tools/visualvm.md
+3-6Lines changed: 3 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,12 +36,9 @@ To capture a heap dump of, for example, a Ruby application for later analysis, s
36
36
Then right-click its process in VisualVM and invoke the Heap Dump action.
37
37
A new heap viewer for the Ruby process opens.
38
38
39
-
__Note:__[Native Image](../reference-manual/native-image/README.md) does not implement the JVMTI agent, so triggering heap dump creation from the Applications area is impossible.
40
-
Apply the `-H:+AllowVMInspection` flag with the `native-image` tool for native image processes.
41
-
This way your application will handle signals and capture a heap dump when it receives the SIGUSR1 signal.
42
-
The guest language REPL process must be started also with the `--jvm` flag to monitor it using VisualVM.
43
-
This functionality is available with [GraalVM Enterprise Edition](https://www.oracle.com/downloads/graalvm-downloads.html).
44
-
It is not available in GraalVM Community Edition.
39
+
__Note:__ Heap dump support must be explicitly enabled when using [Native Image](../reference-manual/native-image/README.md).
40
+
Add the `--enable-monitoring=heapdump,jvmstat` option when invoking the `native-image` tool to enable the heap dump feature and allow VisualVM to detect native executables via `jvmstat`.
41
+
This way your application will handle signals and capture a heap dump when it receives the `SIGUSR1` signal.
45
42
See the [Generating Native Heap Dumps](../reference-manual/native-image/guides/create-heap-dump-from-native-executable.md) page for details on capturing heap dumps from a native image process.
Copy file name to clipboardExpand all lines: substratevm/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ This changelog summarizes major changes to GraalVM Native Image.
9
9
* (GR-40170) Add `--silent` option to silence the build output.
10
10
* (GR-39475) Add initial support for jvmstat.
11
11
* (GR-39563) Add support for JDK 19 and Project Loom Virtual Threads (JEP 425) for high-throughput lightweight concurrency. Enable on JDK 19 with `native-image --enable-preview`.
12
+
* (GR-40264) Add `--enable-monitoring=<all,heapdump,jfr,jvmstat>` option to enable fine-grained control over monitoring features enabled in native executables. `-H:±AllowVMInspection` is now deprecated and will be removed in a future release.
12
13
13
14
## Version 22.2.0
14
15
* (GR-20653) Re-enable the usage of all CPU features for JIT compilation on AMD64.
Copy file name to clipboardExpand all lines: substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java
0 commit comments