callers command displays an inverted call tree, ascending from a method to show its callers. Use it to understand why a method is being called and from where.
Usage
What It Shows
An upward (inverted) tree starting from your specified method and showing:- The method itself
- What calls it (parents)
- What calls those (grandparents)
- Continuing to specified depth
- Percentage of samples where this caller leads to the target method
- Caller method name
Flags
Substring match on method name (required). The method to analyze callers for.
Maximum depth of the callers tree. Controls how many levels of callers to show.
Hide nodes below this percentage threshold. Reduces noise from uncommon call paths.
Remove frames matching this regex before analysis. Useful for collapsing uninteresting intermediate frames.
Shared Flags
Event type:
cpu, wall, alloc, lock, or hardware counter name.Filter to threads containing this substring.
Start of time window (JFR only).
End of time window (JFR only).
Remove idle leaf frames from analysis.
Examples
Basic Callers Tree
HashMap.hashhas 8.3% self-time- It’s called by
HashMap.putin 6.8% of samples - And by
HashMap.getin 5.3% of samples HashMap.putis called byUserService.cacheUser,SessionManager.putSession, etc.
Read the tree bottom-up: lower methods call higher methods. The indentation shows the call chain leading to your target method.
Deeper Callers Analysis
Hide Low-Percentage Callers
Remove Framework Frames
Combined Analysis
Reading the Output
Indentation shows inverted call hierarchy (read bottom-up):- A has 8.3% self-time (appears at top of stack)
- B calls A in 6.8% of samples
- C calls B (which calls A) in 3.2% of samples
- D calls C→B→A in 2.1% of samples
- E calls C→B→A in 1.1% of samples
- F calls B→A in 2.4% of samples
- G calls A directly in 5.3% of samples
Multiple Matches
If-m matches multiple methods, shows callers for each:
Understanding Caller Percentages
The percentages represent how much each caller contributes to the target method:- Total
HashMap.hashself-time: 8.3% - 6.8% of samples came via
HashMap.put - 1.5% of samples came via
HashMap.get - 6.8% + 1.5% = 8.3% (full accounting)
Caller percentages should sum approximately to the target method’s self%. Small discrepancies can occur due to rounding.
When to Use
Root Cause Analysis
Understand why a hot method is called frequently
Optimization Planning
Identify high-level entry points to optimize rather than leaf methods
Architecture Understanding
See how different components use a common method
Refactoring Guidance
Find major callers to understand impact of changing a method
Callers vs Tree
| Command | Direction | Shows | Use Case |
|---|---|---|---|
| callers | Ascending (upward) | Who calls this | Why is this hot? |
| tree | Descending (downward) | What this calls | What does this do? |
- Find hot method with
hot - Use
treeto see what it calls - Use
callersto see why it’s called
Practical Example
Scenario:HashMap.resize is hot (3.1% self-time)
UserCache.put during request processing. Optimization options:
- Pre-size the HashMap in
UserCacheconstructor - Use a different data structure
- Reduce caching frequency