---
title: JVM G1 and ZGC Tuning on AWS Corretto for ECS and EKS
description: Heap too small triggers G1 humongous allocations; too large balloons pause times on Graviton. Corretto on ECS/EKS/Lambda Java—when ZGC generational beats G1 for API heaps.
url: https://www.factualminds.com/blog/jvm-g1-zgc-garbage-collection-tuning-aws/
datePublished: 2026-06-12T00:00:00.000Z
dateModified: 2026-06-12T00:00:00.000Z
author: Palaniappan P
category: Cloud Architecture
tags: engineering-guide, java, performance, aws
---

# JVM G1 and ZGC Tuning on AWS Corretto for ECS and EKS

> Heap too small triggers G1 humongous allocations; too large balloons pause times on Graviton. Corretto on ECS/EKS/Lambda Java—when ZGC generational beats G1 for API heaps.

**Amazon Corretto 21+ (June 2026)** defaults to **G1** on server classpaths; **ZGC** with generational mode targets sub-ms pauses on large heaps (&gt;8 GB).

## Tuning signals on AWS

| Signal             | Action                                         |
| ------------------ | ---------------------------------------------- |
| `Pause Young` high | Increase `-Xmx` or reduce allocation rate      |
| Humongous objects  | Object size &gt; 50% G1 region—fix batch sizes |
| Container OOM      | `-XX:MaxRAMPercentage=75` on ECS/EKS cgroups   |

**Lambda Java** — minimize heap; cold start includes JVM init—consider SnapStart (where supported) or Graal native for latency SLO.

## What to do this week

1. Enable GC logs to CloudWatch via sidecar or JFR snapshots on load test.
2. Match container memory limit to heap + native + metaspace headroom.
3. A/B G1 vs ZGC on same `c7g` task size with identical load.

## What this guide doesn't cover

Virtual threads—part 2 of runtime track.

---

*Source: https://www.factualminds.com/blog/jvm-g1-zgc-garbage-collection-tuning-aws/*
