โ— Shell
clean mode source โ†—

JFR for profiling

Code Comparison

// Install VisualVM / YourKit / JProfiler
// Attach to running process
// Configure sampling
// Export and analyze
// External tool required
// Start with profiling enabled
$ java -XX:StartFlightRecording=
    filename=rec.jfr MyApp

// Or attach to running app:
$ jcmd <pid> JFR.start

Why the modern way wins

๐Ÿ†“

Built-in

No external profiler to install or license.

โšก

Low overhead

~1% performance impact โ€” safe for production.

๐Ÿ“Š

Rich events

CPU, memory, GC, threads, I/O, locks, and custom events.

Old Approach

External Profiler

Modern Approach

Java Flight Recorder

JDK Support

JFR for profiling

Available

Widely available since JDK 9/11 (open-sourced in 11)

How it works

Java Flight Recorder (JFR) is a low-overhead profiling tool built into the JVM. It captures events for CPU, memory, GC, I/O, threads, and custom events with minimal performance impact (~1%).

Related Documentation