ruthst00 commented on code in PR #16545:
URL: https://github.com/apache/grails-core/pull/16545#discussion_r4199212691


##########
grails-doc/src/en/guide/deployment/deploymentTasks.adoc:
##########
@@ -70,6 +70,58 @@ Heap is only part of total memory: allow space for 
metaspace, code cache, direct
 A container can be killed for exceeding its limit even if the Java heap has 
not run out of memory.
 Measure resident memory and GC behavior under load rather than copying a fixed 
heap percentage between applications.
 
+[[java25-memory]]
+=== Java 25 Memory Considerations
+
+Java 25 uses more off-heap memory than earlier LTS releases.
+The most significant change is that the metaspace — the native memory region 
that holds class metadata — is now **unbounded by default**.
+On earlier JDKs the initial metaspace high-water mark was approximately 12 MB; 
on Java 25 there is no upper limit unless you set one explicitly.
+A Grails application that loads many classes (plugins, Hibernate mappings, 
GSP-compiled views) can therefore consume substantially more native memory than 
the same application on Java 21.
+
+In a container environment this matters most: the JVM heap limit (`-Xmx` or 
`-XX:MaxRAMPercentage`) does not cover metaspace, so a container sized only for 
the heap can be killed by the container runtime's OOM killer when metaspace 
grows beyond the remaining native memory budget.
+
+**Recommended settings for Java 25:**
+
+Set an explicit metaspace ceiling so the JVM raises `OutOfMemoryError: 
Metaspace` before the container runtime kills the process:
+
+[source,bash]
+----
+java -Xmx512m -XX:MaxMetaspaceSize=256m -Dgrails.env=prod -jar application.jar
+----
+
+Or, using percentage-based heap sizing in a container:
+
+[source,bash]
+----
+java -XX:MaxRAMPercentage=60.0 -XX:MaxMetaspaceSize=256m -Dgrails.env=prod 
-jar application.jar
+----
+
+Tune `-XX:MaxMetaspaceSize` from a measured baseline: run the application 
under representative load, observe the metaspace usage with `jcmd <pid> 
VM.metaspace` or a monitoring agent, and add a safety margin.
+A typical Grails application with Hibernate and a moderate number of plugins 
stabilizes between 128 MB and 256 MB of metaspace; a large application with 
many plugins may need more.

Review Comment:
   Updated in 
https://github.com/apache/grails-core/pull/16545/changes/e93080d9cd90826ff655f6ccaca02c19ca597e32



##########
grails-doc/src/en/guide/deployment/deploymentTasks.adoc:
##########
@@ -70,6 +70,58 @@ Heap is only part of total memory: allow space for 
metaspace, code cache, direct
 A container can be killed for exceeding its limit even if the Java heap has 
not run out of memory.
 Measure resident memory and GC behavior under load rather than copying a fixed 
heap percentage between applications.
 
+[[java25-memory]]
+=== Java 25 Memory Considerations
+
+Java 25 uses more off-heap memory than earlier LTS releases.
+The most significant change is that the metaspace — the native memory region 
that holds class metadata — is now **unbounded by default**.
+On earlier JDKs the initial metaspace high-water mark was approximately 12 MB; 
on Java 25 there is no upper limit unless you set one explicitly.
+A Grails application that loads many classes (plugins, Hibernate mappings, 
GSP-compiled views) can therefore consume substantially more native memory than 
the same application on Java 21.
+
+In a container environment this matters most: the JVM heap limit (`-Xmx` or 
`-XX:MaxRAMPercentage`) does not cover metaspace, so a container sized only for 
the heap can be killed by the container runtime's OOM killer when metaspace 
grows beyond the remaining native memory budget.
+
+**Recommended settings for Java 25:**
+
+Set an explicit metaspace ceiling so the JVM raises `OutOfMemoryError: 
Metaspace` before the container runtime kills the process:
+
+[source,bash]
+----
+java -Xmx512m -XX:MaxMetaspaceSize=256m -Dgrails.env=prod -jar application.jar
+----
+
+Or, using percentage-based heap sizing in a container:
+
+[source,bash]
+----
+java -XX:MaxRAMPercentage=60.0 -XX:MaxMetaspaceSize=256m -Dgrails.env=prod 
-jar application.jar
+----
+
+Tune `-XX:MaxMetaspaceSize` from a measured baseline: run the application 
under representative load, observe the metaspace usage with `jcmd <pid> 
VM.metaspace` or a monitoring agent, and add a safety margin.
+A typical Grails application with Hibernate and a moderate number of plugins 
stabilizes between 128 MB and 256 MB of metaspace; a large application with 
many plugins may need more.
+
+If you also want to control how aggressively the JVM reclaims unused metaspace 
after a GC cycle, set the free-ratio bounds:
+
+[source,bash]
+----
+-XX:MinMetaspaceFreeRatio=20 -XX:MaxMetaspaceFreeRatio=80

Review Comment:
   Updated in 
https://github.com/apache/grails-core/pull/16545/changes/e93080d9cd90826ff655f6ccaca02c19ca597e32



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to