Title: Garbage Collection in Java: Java GC — Unbounded Cache Full
Open Graph Title: Garbage Collection in Java: Java GC — Unbounded Cache Full
Description: G1 Full GC from unbounded cache spikes p99 latency to 30s+ and kills Kubernetes pods. Doubling heap fails— learn why only a bounded eviction fixes it.
Open Graph Description: G1 Full GC from unbounded cache spikes p99 latency to 30s+ and kills Kubernetes pods. Doubling heap fails— learn why only a bounded eviction fixes it.
Opengraph URL: https://thecodeforge.io/java/garbage-collection-java/
Domain: thecodeforge.io
{
"@context": "https://schema.org",
"@type": "TechArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://thecodeforge.io/java/garbage-collection-java/"
},
"headline": "Java GC — Unbounded Cache Full GC Spiral",
"description": "G1 Full GC from unbounded cache spikes p99 latency to 30s+ and kills Kubernetes pods. Doubling heap fails— learn why only a bounded eviction fixes it.",
"keywords": "Java GC — Unbounded Cache Full GC Spiral, Java, Advanced, Advanced Java, G1 Full GC from unbounded cache spikes p99 latency to 30s+ and kills Kubernetes pods. Doubling heap fails— learn why only a bounded eviction fixes it.",
"proficiencyLevel": "Expert",
"author": {
"@type": "Person",
"@id": "https://thecodeforge.io/about/#naren",
"name": "Naren",
"url": "https://thecodeforge.io/about/"
},
"publisher": {
"@type": "Organization",
"@id": "https://thecodeforge.io/#org",
"name": "TheCodeForge",
"url": "https://thecodeforge.io",
"logo": {"@type": "ImageObject", "url": "https://thecodeforge.io/assets/og-image.png"}
},
"datePublished": "2026-03-05T00:00:00+00:00",
"dateModified": "2026-08-30T00:00:00+00:00",
"url": "https://thecodeforge.io/java/garbage-collection-java/",
"inLanguage": "en",
"educationalLevel": "Advanced",
"image": "https://thecodeforge.io/assets/og-image.png",
"isPartOf": {"@id": "https://thecodeforge.io/#website"}
}
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": "https://thecodeforge.io/"},
{"@type": "ListItem", "position": 2, "name": "Java", "item": "https://thecodeforge.io/java/"},
{"@type": "ListItem", "position": 3, "name": "Java GC — Unbounded Cache Full GC Spiral", "item": "https://thecodeforge.io/java/garbage-collection-java/"}
]
}
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is the difference between a young GC and a full GC?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Young GC collects only the young generation (eden and survivor) and is fast because most objects die young. Full GC collects the entire heap, compacting all regions, and can take seconds or tens of seconds. Full GC should be a rare event in a well-tuned service."
}
},
{
"@type": "Question",
"name": "How do I enable GC logging for a running JVM without restarting?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Use `jcmd VM.log output=gc.log what=gc*` (JDK 10+). For JDK 8/9, you need to restart with `-Xloggc:` or use `-XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:+PrintGCDetails -XX:+PrintGCDateStamps`. For persistent change, add the flag to the JVM startup command."
}
},
{
"@type": "Question",
"name": "What is the recommended heap size for a containerized Java application?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Set -XX:MaxRAMPercentage=75.0 (or -XX:MaxRAMFraction=1) so the JVM uses 75% of container memory for heap. The remaining 25% is for native memory (threads, metaspace, GC overhead). Never set -Xmx equal to container memory limit."
}
},
{
"@type": "Question",
"name": "Why does my application run out of memory even though the heap is not full?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Check native memory: metaspace, thread stacks, direct byte buffers, code cache, GC structures. Use `-XX:NativeMemoryTracking=detail` and `jcmd VM.native_memory summary`. Metaspace leaks from class loader re-deployment are a common cause."
}
}
]
}
| og:type | website |
| og:image | https://thecodeforge.io/assets/og-image.png |
| og:image:width | 1200 |
| og:image:height | 630 |
Links:
Viewport: width=device-width, initial-scale=1.0
Robots: max-image-preview:large