All Products
Search
Document Center

Enterprise Distributed Application Service:Configure dynamic heap memory optimization

Last Updated:Mar 11, 2026

Java applications in containers often retain heap memory long after it is needed, preventing the operating system from reclaiming it for other workloads. Dynamic heap memory optimization solves this by periodically returning unused heap memory to the OS. This reduces the memory footprint per application, fits more pod replicas per node in Container Service for Kubernetes (ACK) clusters, and lowers resource costs in Serverless Kubernetes clusters.

How it works

When you enable dynamic heap memory optimization, Enterprise Distributed Application Service (EDAS) adds the -XX:G1PeriodicGCInterval parameter and sets it to 60000 (60 seconds) for applications using the G1 GC policy, adjusting the JVM collection policy to periodically return unused heap memory to the operating system.

EDAS also adjusts the initial heap size (Xms) to 128 MB to maximize the memory range available for dynamic optimization. This creates a wide gap between the initial and maximum heap size, giving the JVM room to scale heap usage up or down based on actual demand.

Requirements

All of the following must be met. The feature cannot be enabled otherwise.

RequirementValueDetails
JDK versionDragonwell_11_ElasticHeapChanging the JDK version after enablement automatically disables the feature.
GC policyG1Both the Young Generation GC Policy and Old Generation GC Policy must be set to G1. Changing the GC policy after enablement automatically disables the feature.
Maximum heap memoryXmx must be setThe feature requires a defined maximum heap size.
Initial heap memoryXms < XmxIf Xms equals Xmx, EDAS resets Xms to 128 MB upon enablement.

Monitoring (optional)

Monitoring is not required for the optimization to work, but provides visibility into memory trends.

ServiceMetrics provided
Application Real-Time Monitoring Service (ARMS)Heap Memory Usage and JVM Memory Usage Trend
Managed Service for PrometheusPod Memory Usage

Enable for a new application

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. Select a region in the top navigation bar, select a microservices namespace from the Microservices Namespace drop-down list, and then click Create Application.

  3. In the Basic Information step, configure the following parameters:

    ParameterValue
    Cluster TypeKubernetes Clusters
    Application Runtime EnvironmentJava -- Select Java for a JAR package (Dubbo or Spring Boot). You can reconfigure the Java Environment parameter after you select this option. Select Tomcat for a WAR package (Dubbo or Spring). You can reconfigure the Java Environment and Container Version parameters after you select this option.
    Java EnvironmentDragonwell_11_ElasticHeap
  4. In the Monitoring and Governance Solution section, select Integrated Solution (Default) and click Next.

  5. In the Configurations step, configure the environment, basic information, deployment mode, and resource parameters, and then click Next.

  6. In the Advanced Settings step, click Edit next to Settings of Java Startup Parameters. In the Edit Java Startup Parameters dialog box:

    • Set Initial Heap Size and Maximum Heap Memory.

    • Set both Young Generation GC Policy and Old Generation GC Policy to G1.

    • Click OK.

  7. Click Dynamic Heap Memory Optimization and turn on Whether to Enable Dynamic Heap Memory Optimization.

Enable for an existing application

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications. Select a region and namespace, select Container Service or Serverless Kubernetes Cluster from the Cluster Type drop-down list, and then click the target application name.

  3. On the Overview or Basic information page, choose Deploy > Deploy in the upper-right corner.

  4. On the Select Deployment Mode page, select a deployment mode and click Start Deployment.

  5. On the deployment settings page:

    • Set Application Runtime Environment to Java and Java Environment to Dragonwell_11_ElasticHeap.

    • Configure the deployment package.

    • Click Edit next to Settings of Java Startup Parameters. In the Edit Java Startup Parameters dialog box, set Initial Heap Size and Maximum Heap Memory, set both GC policies to G1, and click OK.

  6. Click Dynamic Heap Memory Optimization to view and configure the optimization settings.

Verify the feature is active

Use either method to confirm that the deployment succeeded and dynamic heap memory optimization is in effect:

  • Change list: Open the Change List page for the application. If Execution status shows Success, the feature is active.

  • Pod status: On the Application Overview page, click the pod status link next to Running Status. In the Pod section, a green icon in the Status column confirms the application is running with the optimization enabled.

Monitor optimization results

Metrics

EDAS calculates memory usage metrics based on application behavior over the last 15 minutes:

  • Heap memory usage = Average used heap memory / Average used pod memory (over the last 15 minutes)

  • Average used heap memory = Mean of JVM heap usage samples collected once per minute over 15 minutes

  • Average used pod memory = Mean of maximum pod memory samples collected once per minute over 15 minutes

Charts

The optimization dashboard displays memory trends over the last seven days, with one data point per day:

ChartWhat it showsData source
Pod Memory UsagePod-level memory consumptionPrometheus
JVM HeapApplication heap memoryARMS
JVM Old GenerationOld generation memoryARMS

Tune optimization parameters

Default parameter adjustments

When you enable dynamic heap memory optimization, EDAS automatically applies the following adjustments:

ConditionAdjustment
Only Xmx is configured (no Xms)Xms is set to 128 MB
Xmx equals XmsXms is reset to 128 MB
G1 GC policy is active-XX:G1PeriodicGCInterval is set to 60000 (60-second periodic GC interval)

Custom parameters

To reserve more memory for the application and reduce the amount returned to the OS, adjust the heap free ratio parameters. Configure them as custom Java startup parameters. For configuration steps, see Configure Java startup parameters. For parameter details, see Java Documentation.

ParameterWhat it controlsDefaultExample
MaxHeapFreeRatioMaximum percentage of idle heap memory allowed before the JVM shrinks the heap70% (HotSpot JDK 8, 11, 17)-XX:MaxHeapFreeRatio=80
MinHeapFreeRatioMinimum percentage of idle heap memory the JVM maintains before expanding the heap40% (HotSpot JDK 8, 11, 17)-XX:MinHeapFreeRatio=50

Increasing MaxHeapFreeRatio allows the application to retain more idle heap memory, reducing the frequency of memory release to the OS. Decreasing MinHeapFreeRatio allows the JVM to operate with less free heap before triggering expansion.