Overview
Thefilter command searches for stacks containing a specific method and outputs them in collapsed stack format. This is useful for:
- Isolating code paths that call a particular method
- Creating focused profiles for specific functionality
- Piping filtered stacks to other analysis tools
Usage
Flags
Required. Substring to match on method name. Short name or FQN matching.
Include caller frames (frames above the matched method). By default, only frames from the matched method to the leaf are shown.
Shared Flags
Common flags supported by most commands:Event type:
cpu, wall, alloc, lock, or hardware counter nameFilter to threads matching substring
Start time of window (JFR only)
End time of window (JFR only)
Output Format
Outputs stacks in collapsed format:- One stack per line
- Frames separated by semicolons
- Optional thread name prefix in brackets
- Sample count at the end
--include-callers, shows the entire stack (root to leaf).
Examples
Basic Filtering
Find all stacks callingHashMap.resize:
Include Caller Context
Show full stacks including callers:Filter and Analyze
Pipe filtered stacks tohot for a focused analysis:
Filter Specific Thread
Combine thread and method filtering:Filter Specific Event
Find allocation stacks involvingArrayList:
Time Window Filtering
Filter stacks from a specific time range:Pattern Matching
The-m flag performs substring matching on both short names and fully-qualified names:
Pattern matching is case-sensitive substring search, not regex. Use the script command with
match() for regex patterns.Use Cases
Isolate Feature Paths
Extract all stacks related to authentication:Investigate Hotspot
Afterhot identifies an expensive method, filter to see its call paths:
Create Focused Flamegraph
Generate a flamegraph for specific functionality:Compare Filtered Profiles
Compare how a specific method performs in two runs:Debug Missing Matches
If no stacks match, verify the method exists:Empty Results
If no stacks match, you’ll see:- Method name typo or case mismatch
- Method not present in the selected event type (try
--event wallor--event alloc) - Method filtered out by
--threador time window - Method exists but was not sampled (not in hot path)