Polishing

This commit is contained in:
Sam Brannen
2023-11-21 09:36:01 +01:00
parent fff50657d2
commit 3290260ef0
2 changed files with 18 additions and 17 deletions

View File

@@ -2,7 +2,7 @@
= Class Data Sharing
Class Data Sharing (CDS) is a https://docs.oracle.com/en/java/javase/17/vm/class-data-sharing.html[JVM feature]
that can help reduce the startup time and memory footprints of Java applications.
that can help reduce the startup time and memory footprint of Java applications.
To use this feature, a CDS archive should be created for the particular classpath of the
application. The Spring Framework provides a hook-point to ease the creation of the
@@ -12,15 +12,16 @@ archive. Once the archive is available, users should opt in to use it via a JVM
A CDS archive for an application can be created when the application exits. The Spring
Framework provides a mode of operation where the process can exit automatically once the
`ApplicationContext` has refreshed. In this mode, all non-lazy initialized singletons are
instantiated, `InitializingBean#afterPropertiesSet` callbacks have been invoked, but the
lifecycle has not started and `ContextRefreshedEvent` has not been published.
`ApplicationContext` has refreshed. In this mode, all non-lazy initialized singletons
have been instantiated, and `InitializingBean#afterPropertiesSet` callbacks have been
invoked; but the lifecycle has not started, and the `ContextRefreshedEvent` has not yet
been published.
To create the archive, two additional JVM flags must be specified:
* `-XX:ArchiveClassesAtExit=app-cds.jsa`: creates the CDS archive on exit
* `-Dspring.context.exit=onRefresh`: starts and then immediately exit your Spring
application as described above.
* `-Dspring.context.exit=onRefresh`: starts and then immediately exits your Spring
application as described above
To create a CDS archive, your JDK must have a base image. If you add the flags above to
your startup script, you may get a warning that looks like this: