-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathjfr-profiling.yaml
More file actions
52 lines (51 loc) · 1.61 KB
/
jfr-profiling.yaml
File metadata and controls
52 lines (51 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
id: 83
slug: "jfr-profiling"
title: "JFR for profiling"
category: "tooling"
difficulty: "intermediate"
jdkVersion: "9"
oldLabel: "Java 8"
modernLabel: "Java 9+"
oldApproach: "External Profiler"
modernApproach: "Java Flight Recorder"
oldCode: |-
// Install VisualVM / YourKit / JProfiler
// Attach to running process
// Configure sampling
// Export and analyze
// External tool required
modernCode: |-
// Start with profiling enabled
$ java -XX:StartFlightRecording=
filename=rec.jfr MyApp
// Or attach to running app:
$ jcmd <pid> JFR.start
summary: "Profile any Java app with the built-in Flight Recorder — no external tools."
explanation: "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%)."
whyModernWins:
- icon: "🆓"
title: "Built-in"
desc: "No external profiler to install or license."
- icon: "⚡"
title: "Low overhead"
desc: "~1% performance impact — safe for production."
- icon: "📊"
title: "Rich events"
desc: "CPU, memory, GC, threads, I/O, locks, and custom events."
support:
state: "available"
description: "Widely available since JDK 9/11 (open-sourced in 11)"
prev: "tooling/multi-file-source"
next: "tooling/compact-object-headers"
related:
- "tooling/multi-file-source"
- "tooling/jshell-prototyping"
- "tooling/single-file-execution"
docs:
- title: "JDK Flight Recorder"
href: "https://docs.oracle.com/en/java/javase/25/docs/specs/man/jfr.html"
- title: "Flight Recorder API (JEP 328)"
href: "https://openjdk.org/jeps/328"