# Diagnosing high p99 latency caused by Java garbage collection pauses

DevFeed: [Diagnosing high p99 latency caused by Java garbage collection pauses](<https://devfeed.tech/articles/your-p99-is-a-garbage-collector-setting-60525.md>)

Original publisher: [Read original article](<https://ankit-rana.com/logs/59-p99-is-a-garbage-collector-setting/>)

Author: hello@ankit-rana.com

Published: 2026-09-27T00:00:00Z

Content type: article

Language: en

Sources: [Ankit Rana | Mechanical Sympathy](<https://devfeed.tech/sources/ankit-rana-mechanical-sympathy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Running Median](<https://devfeed.tech/topics/running-median.md>), [proguard](<https://devfeed.tech/topics/proguard.md>)

Tags: [cost](<https://devfeed.tech/tags/cost.md>), [garbage-collection](<https://devfeed.tech/tags/garbage-collection.md>), [java](<https://devfeed.tech/tags/java.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [latency](<https://devfeed.tech/tags/latency.md>), [logs](<https://devfeed.tech/tags/logs.md>), [median](<https://devfeed.tech/tags/median.md>), [observability](<https://devfeed.tech/tags/observability.md>), [performance](<https://devfeed.tech/tags/performance.md>)

## AI overview

The article explains how stop-the-world garbage collection can cause p99 latency to rise even when application code paths are fast. It recommends comparing GC pause logs with request timestamps and explains how allocation rate, object retention, and heap size affect collection frequency and pause duration.

## Source excerpt

A p99 that is many times the median with no matching slow code path is usually a stop the world garbage collection pause, which stops every application thread regardless of what it was doing. The lever is allocation rate rather than heap size, because most collectors scale their work with the number of surviving objects and the frequency of collection follows directly from how fast you fill the young generation. Enlarging the heap reduces collection frequency and can lengthen each pause, which trades a common small delay for a rare large one.