← ClaudeAtlas

code-cache-segmentslisted

The JDK 17-25 segmented code cache, GC-driven unloading, fragmentation, segment sizing, and jcmd Compiler.codecache/CodeHeap_Analytics. Use when aggregate usage looks healthy but one CodeHeap is exhausted, compilation stops or restarts, GC logs show a CodeCache cause, startup rejects manual heap sizes, an OutOfMemoryError reports "Out of space in CodeCache", or a long-running service degrades while aggregate free space remains. Covers runtime-shape discovery so tools do not assume exactly three heaps on every mode or release. Excludes the introductory exhaustion signature (jit-compilation), container memory budgeting (jvm-memory-regions), and Metaspace internals (metaspace-internals).
robsonkades/agent-skills · ★ 2 · AI & Automation · score 75
Install: claude install-skill robsonkades/agent-skills
# Code Cache Segments ## Purpose On JDK 17-25, treat the normally segmented code cache as three independent allocators with separate ceilings. One `CodeHeap` can sit at 99.8% while the consolidated number reads 72%, and every tool that stops at the consolidated line reports a healthy system. Since JDK 20 the consequence of one full heap is not "the compiler stops": the allocator falls back to the other nmethod heap, so short-lived tier-3 code starts landing in the heap that was reserved for long-lived C2 code, and the GC-driven unloading that replaced the sweeper keys off the **aggregate** free ratio and does not notice. Compilation stops only when the allocation cannot be satisfied after the applicable fallback. Do not hard-code a count of three into tooling: unsegmented and interpreter-only modes have fewer heaps, and later HotSpot builds can add heap kinds. Discover the runtime shape from `Compiler.codecache` and `jdk.CodeCacheConfiguration`. The second failure this prevents is the reflexive "double `ReservedCodeCacheSize`". It works when the pressured segment happens to be one of the two that split the remainder 50/50, and wastes half the increase when it is not — or when the real cost was the GC pauses the code cache was triggering, which a bigger cache also fixes, for a different reason. ## Workflow Before collecting evidence, pin vendor/update, architecture, collector, compiler mode and effective startup flags from the deployed runtime and its CI/image configurati