GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • java.evolved
  • ←
  • →

This view

  • Original page
  • New address

GeezerVison is showing javaevolved.dev — JFR for profiling | java.evolved

Home / Tooling / JFR for profiling
Tooling Intermediate

JFR for profiling

  • 🐛 Report a code issue
  • 🌐 Report a translation issue
  • 💡 Suggest a new pattern

Profile any Java app with the built-in Flight Recorder — no external tools.

Tooling Performance
Code Comparison
✕ Java 8
// Install VisualVM / YourKit / JProfiler
// Attach to running process
// Configure sampling
// Export and analyze
// External tool required
✓ Java 9+
// Start with profiling enabled
$ java -XX:StartFlightRecording=
    filename=rec.jfr MyApp

// Or attach to running app:
$ jcmd <pid> JFR.start
Share 𝕏
See a problem with this code? Let us know.
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
Since JDK
9
Difficulty
Intermediate
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
JDK Flight Recorder ↗ Flight Recorder API (JEP 328) ↗
Related patterns
Tooling Intermediate

Multi-file source launcher

Java 8
$ javac *.java
$ java Main
// Must compile all files first
// Need a build tool for dependencies
Java 22+
$ java Main.java
// Automatically finds and compiles
// other source files referenced
// by Main.java
Hover to see modern ➜
JDK 22+ →
Tooling Beginner

JShell for prototyping

Java 8
// 1. Create Test.java
// 2. javac Test.java
// 3. java Test
// Just to test one expression!
Java 9+
$ jshell
jshell> "hello".chars().count()
$1 ==> 5
jshell> List.of(1,2,3).reversed()
$2 ==> [3, 2, 1]
Hover to see modern ➜
JDK 9+ →
Tooling Beginner

Single-file execution

Java 8
$ javac HelloWorld.java
$ java HelloWorld
// Two steps every time
Java 11+
$ java HelloWorld.java
// Compiles and runs in one step
// Also works with shebangs:
#!/usr/bin/java --source 25
Hover to see modern ➜
JDK 11+ →
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.