java
10 minJava Thread Dumps: Find Deadlocks, Starvation, and Lock Contention
Use repeated thread dumps and thread-state patterns to distinguish deadlocks from slow dependencies, starvation, and excessive synchronization.
Loading page...
java
10 minUse repeated thread dumps and thread-state patterns to distinguish deadlocks from slow dependencies, starvation, and excessive synchronization.
Q&A
Q&ACompare post-GC live-set size and object retention paths over time.
High allocation can cause frequent collections while post-GC occupancy remains broadly stable. A leak tends to retain objects that should have become unreachable, so compare heap dumps and dominator paths across time. Check allocation rate, live set, GC logs, and process/container memory together before changing heap settings.
Q&A
Q&AHeap or native-resource exhaustion differs from exhausting one thread call stack.
OutOfMemoryError identifies an allocation resource that could not be satisfied, such as Java heap, metaspace, direct buffers, or native threads. StackOverflowError usually indicates an excessively deep call chain or runaway recursion in one thread. Read the exact message, capture JVM and container metrics, and use a heap dump or thread stack evidence before changing memory flags.
Q&A
Q&AIt is no longer strongly reachable from GC roots, though collection timing is not guaranteed.
An object becomes eligible when no strong-reference path leads to it from roots such as live thread stacks, static fields, or JNI references. Eligibility does not guarantee immediate collection or finalization. To diagnose retention, inspect heap dumps and dominator paths; do not rely on System.gc() as a fix.
java
11 minSeparate heap pressure from thread-stack failure, collect the right evidence, and fix the retention path rather than masking symptoms.
Q&A
Q&AUse repeated thread dumps and lock profiling to locate hot locks, then reduce serialization safely.
Capture repeated thread dumps and identify many threads blocked on the same owner or monitor. Use a profiler or JFR lock events to quantify contention and critical-section time. Reduce lock scope, shard independent state, batch updates, or use concurrent primitives only when they preserve the invariant; verify throughput and correctness under representative load.
Q&A
Q&AFind a cycle in lock ownership and waiting, then remove inconsistent nested lock ordering.
Capture repeated thread dumps with jcmd or jstack while the incident is active. A deadlock cycle shows threads waiting for locks held by each other; distinguish it from starvation or a slow dependency by checking whether owners can progress. Fix consistent lock order, shorten critical sections, or redesign ownership so both locks are not required together.