Use Flight Recorder, which is built into the JVM and designed for low overhead continuous recording. Start it with jcmd on a running process, capture a window, and open the recording in Mission Control to see hot methods, allocation by site, lock contention, garbage collection and exception rates. For flame graphs of native and Java frames together, an async profiler is the usual companion, and heap dumps stay the tool for leaks.
Why interviewers ask this
The interviewer is checking that you can investigate a live system with real tools rather than adding timing logs and redeploying. Knowing Flight Recorder is bundled and safe to run in production, and that the interesting views are allocation and lock contention rather than only CPU, is the differentiator. It also opens the discussion of profiling honestly, since a benchmark on a warm JIT is not the same as production.
How to structure your answer
- Name the built in tool and why it is safe in production.
- Describe how you start a recording on a running process.
- Say which views you look at and in what order.
- Add complementary tools for leaks and flame graphs.
Example answer
Flight Recorder first, because it ships with the JVM and the default profile has low enough overhead to leave running. I attach with jcmd on the running process, record a few minutes that includes the slow behavior, dump it and open it in Mission Control. The order I look at things depends on the symptom. For CPU I go to hot methods, but for latency I usually learn more from allocation by call site, because excessive allocation drives collection pauses, and from lock contention, which is where a synchronized block in a hot path shows up immediately. Garbage collection and exception rates are on the same recording, so I can correlate rather than guess. If I want a flame graph that shows native frames alongside Java, I use an async profiler, which also avoids the safepoint bias that older sampling profilers had. For memory leaks the tool is a heap dump and a dominator tree, since a profile shows me allocation, not retention. And I always compare against a baseline recording from a healthy period, because a profile on its own has no sense of normal.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- What overhead does the default Flight Recorder profile add?
- What is safepoint bias, and why does it matter for profilers?
- How would you profile a startup problem rather than a steady state one?
Related java developer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions