Skip to content

Commit

Permalink
[GR-60094] Test and review Native Image guides with JDK 24-EA. Part 3
Browse files Browse the repository at this point in the history
PullRequest: graal/19631
  • Loading branch information
olyagpl committed Dec 20, 2024
2 parents 9fbe4bd + 9011cf4 commit 545c9ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
1 change: 0 additions & 1 deletion docs/getting-started/oci/code-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,5 @@ The Code Editor allows you to accomplish quick coding tasks and run applications

- [Java Hello World with Oracle GraalVM in OCI Code Editor](https://github.com/oracle-devrel/oci-code-editor-samples/tree/main/java-samples/graalvmee-java-hello-world)
- [Micronaut Hello World REST App with Oracle GraalVM in OCI Code Editor](https://github.com/oracle-devrel/oci-code-editor-samples/tree/main/java-samples/graalvmee-java-micronaut-hello-rest)
- [Spring Boot Microservice with Oracle GraalVM in OCI Code Editor](https://github.com/graalvm/graalvm-demos/blob/master/spring-native-image/README-Code-Editor.md)
- [Working with Code Editor](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/code_editor_intro.htm)
- [Oracle GraalVM in OCI Cloud Shell](cloud-shell.md)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You will use a GraalVM container image with Native Image to compile a Java appli

## Download a Sample Application

This guide uses the [Spring Boot 3 Native Image Microservice example](https://github.com/graalvm/graalvm-demos/tree/master/native-image/containerize/src/main/java/com/example/benchmarks/jibber).
This guide uses the [Spring Boot 3 Native Image Microservice example](https://github.com/graalvm/graalvm-demos/tree/master/native-image/containerize/spring-boot-microservice-jibber/src/main/java/com/example/benchmarks/jibber).
The example is a minimal REST-based API application, built on top of Spring Boot 3.
If you call the HTTP endpoint `/jibber`, it will return some nonsense verse generated in the style of the Jabberwocky poem, by Lewis Carroll.

Expand All @@ -38,7 +38,7 @@ For other installation options, visit the [Downloads section](https://www.graalv

3. Change directory to _native-image/containerize/_:
```shell
cd graalvm-demos/native-image/containerize
cd graalvm-demos/native-image/containerize/spring-boot-microservice-jibber
```

## Build and Run as a Native Executable
Expand Down Expand Up @@ -115,4 +115,4 @@ With GraalVM Native Image you can also [build fully static native executables](b

* [Build a Native Executable from a Spring Boot Application](build-spring-boot-application-aot.md)
* <a href="https://docs.oracle.com/en/graalvm/jdk/23/docs/getting-started/container-images/" target="_blank">Oracle GraalVM Container Images</a>
* <a href="https://luna.oracle.com/lab/fdfd090d-e52c-4481-a8de-dccecdca7d68" target="_blank">Hands-on Lab: GraalVM Native Image, Spring and Containerisation</a>
* <a href="https://luna.oracle.com/lab/fdfd090d-e52c-4481-a8de-dccecdca7d68" target="_blank">Hands-on Lab: GraalVM Native Image, Spring and Containerisation</a>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ For example:

```shell
./mem-leak-example -XX:+HeapDumpOnOutOfMemoryError
```
You should see a similar output:
```
Dumping heap to svm-heapdump-67799-OOME.hprof ...
Heap dump file created [10046752 bytes in 0.49 secs]
Exception in thread "main" java.lang.OutOfMemoryError: Garbage-collected heap size exceeded.
Expand All @@ -54,11 +57,14 @@ This can be useful to identify which objects the Native Image build process allo
For a HelloWorld example, use the option as follows:

```shell
$JAVA_HOME/bin/native-image HelloWorld --enable-monitoring=heapdump
native-image HelloWorld --enable-monitoring=heapdump
```
```shell
./helloworld -XX:+DumpHeapAndExit
Heap dump created at '/path/to/helloworld.hprof'.
```

The heap dump is created at _path/to/helloworld.hprof_.

## Create a Heap Dump with SIGUSR1 (Linux/macOS only)

> Note: This requires the `Signal` API, which is enabled by default except when building shared libraries.
Expand Down Expand Up @@ -176,6 +182,9 @@ For other installation options, visit the [Downloads section](https://www.graalv
Run the application:
```shell
./svmheapdump
```
You should see a similar output:
```
17 May 2022, 16:38:13: Hello GraalVM native image developer!
The PID of this process is: 57509
Send it a signal: 'kill -SIGUSR1 57509'
Expand Down Expand Up @@ -285,11 +294,12 @@ The condition to create a heap dump is provided as an option on the command line
```
When the command completes, the _svmheapdumpapi_ native executable is created in the current directory.

3. Run the application and check the heap dump

Now you can run your native executable and create a heap dump from it with output similar to the following:
3. Run the application and create a heap dump:
```shell
./svmheapdumpapi --heapdump
```
You should see a similar output:
```
Sep 15, 2020, 4:06:36 PM: Hello GraalVM native image developer.
Your command line options are: --heapdump
Heap dump created /var/folders/hw/s9d78jts67gdc8cfyq5fjcdm0000gp/T/SVMHeapDump-6437252222863577987.hprof, size: 8051959
Expand Down

0 comments on commit 545c9ef

Please sign in to comment.