tree command displays a call tree starting from a method and descending to its callees. Use it to understand what a method calls and where time is spent downstream.
Usage
What It Shows
A hierarchical, indented tree showing:- The root method (or all roots if no method specified)
- What it calls (children)
- What those call (grandchildren)
- Continuing to specified depth
- Total percentage (samples containing this node)
- Self percentage (samples where this is the leaf)
- Method name
Flags
Substring match on method name. If specified, tree starts from matching method(s). If omitted, shows full profile tree from all roots.
Maximum depth of the tree. Controls how many levels of callees to show.
Hide nodes below this percentage threshold. Reduces noise from uncommon paths.
Remove frames matching this regex before analysis. Useful for collapsing uninteresting intermediate frames.Example:
--hide "java\.util\..*" removes all java.util 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 Tree from Method
total=X% means X% of all samples pass through this method. self=Y% means Y% of samples have this as the leaf frame.Full Profile Tree
Deeper Tree
Hide Low-Percentage Nodes
Remove Framework Frames
Combined Filters
Reading the Output
Indentation shows call hierarchy:- A calls B and E
- B calls C and D
- 40% of samples contain A
- 5% of samples have A as the leaf (A doing work)
- 25% of samples pass through B (called by A)
- 10% of samples have B as the leaf
Multiple Matches
If-m matches multiple methods, the tree shows all matches:
When to Use
Understanding Hot Methods
After finding a hot method with
hot, use tree to see what it callsIdentifying Expensive Callees
Discover which downstream methods consume the most time
Algorithm Analysis
Understand the execution flow and call patterns
Finding Hidden Costs
Spot expensive operations buried in call chains
Tree vs Trace vs Callers
| Command | Direction | Shows | Use Case |
|---|---|---|---|
| tree | Descending | All callees | What does this call? |
| trace | Descending | Hottest path only | Critical path analysis |
| callers | Ascending | Who calls this | Why is this called? |