github/awesome-copilot / skills/java-diagnostics
java-diagnostics
VerifiedSymptom-first runtime diagnostics for JVM applications using JDK tools: jcmd, jstack, jmap, jstat, JFR, GC logs, async-profiler, Native Memory Tracking, and Eclipse MAT. Use when a Java app has high CPU, memory leaks or OutOfMemoryError, slow startup, deadlocks or thread starvation, long GC pauses, native memory growth, or slow requests. Includes permission tiers for safe use.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.2 KB |
| references/async-profiler.md | markdown | 3.0 KB |
| references/containers.md | markdown | 1.7 KB |
| references/gc.md | markdown | 1.6 KB |
| references/heap.md | markdown | 3.0 KB |
| references/jcmd-basics.md | markdown | 1.9 KB |
| references/jfr.md | markdown | 2.3 KB |
| references/native-memory.md | markdown | 1.5 KB |
| references/thread-dumps.md | markdown | 3.3 KB |
references/containers.md
View on GitHub# Containers
## Memory sizing
- The JVM is container-aware (cgroup limits) in JDK 10+ and 8u191+.
- Heap defaults to 25% of the container limit. Use `-XX:MaxRAMPercentage=75.0` (or lower, e.g. 50-70, if there is significant native/off-heap usage) instead of a fixed `-Xmx`, so the heap scales with the limit.
- Leave headroom for metaspace, thread stacks, code cache, direct buffers; an OOM-kill (exit code 137, `OOMKilled`) with a healthy heap points to native memory growth (see [native-memory](native-memory.md)).
- Verify what the JVM sees: `java -XX:+PrintFlagsFinal -version | grep -E 'MaxHeapSize|MaxRAMPercentage|ActiveProcessorCount'` and `jcmd <pid> VM.flags`.
## Attaching tools
- `jcmd`/`jstack` must run **inside the container** (same PID namespace and user): `docker exec -it <c> jcmd 1 Thread.print`, `kubectl exec <pod> -- jcmd 1 Thread.print`. JRE-only images lack these tools.
- Do not rebuild production images to add tools. Prefer an ephemeral debug container sharing the process namespace (`kubectl debug -it <pod> --image=<jdk-image> --target=<container>`), and only with explicit consent.
- Output files are written by the target JVM inside the container's filesystem; copy them out with `kubectl cp` / `docker cp`, then delete them in the container. Mind ephemeral storage limits for heap dumps.
- Tier 1/2/3 rules apply unchanged; production pods require explicit user instruction.
## CPU
Few CPUs or CFS throttling cause latency and GC thread starvation. Check `-XX:ActiveProcessorCount`, throttling metrics (`container_cpu_cfs_throttled_seconds_total`), and thread-pool sizing.
## Debugging
See the `java-debugging` skill for JDWP port mapping to `127.0.0.1`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |