oracle / oracle/visualvm

Feature request: allow sampling snapshot recording from command line only in headless environment

Open
#380 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
3.3k
Forks
334
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.
I would like to be able to record snapshots of sampled CPU usage from the command line in a headless environment, and then later open that snapshot in the VisualVM GUI. The command line docs suggest that it's possible to start and stop sampling from a command line, but there doesn't seem to be a working option to dump that information to a snapshot file.

Describe the solution you'd like
New command line option to dump CPU (or memory) sampling results to a file that can be loaded in the GUI later

Describe alternatives you've considered
I have tried the following series of commands, hoping that it might work, but it doesn't seem to do anything:

[kmilner@e19-12 ~]$ mkdir /tmp/visualvm_temp/
[kmilner@e19-12 ~]$ ~/visualvm_21/bin/visualvm -J-Dvisualvm.tmpdir=/tmp/visualvm_temp/ --start-cpu-sampler 31650
/home1/kmilner/visualvm_21/platform/lib/nbexec: WARNING: environment variable DISPLAY is not set
^Z
[1]+  Stopped                 ~/visualvm_21/bin/visualvm -J-Dvisualvm.tmpdir=/tmp/visualvm_temp/ --start-cpu-sampler 31650
[kmilner@e19-12 ~]$ bg
[1]+ ~/visualvm_21/bin/visualvm -J-Dvisualvm.tmpdir=/tmp/visualvm_temp/ --start-cpu-sampler 31650 &
[kmilner@e19-12 ~]$ ~/visualvm_21/bin/visualvm -J-Dvisualvm.tmpdir=/tmp/visualvm_temp/ --snapshot-sampler 31650
/home1/kmilner/visualvm_21/platform/lib/nbexec: WARNING: environment variable DISPLAY is not set
[kmilner@e19-12 ~]$ ls /tmp/visualvm_temp/
[kmilner@e19-12 ~]$

Additional context
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the command-line options documented at the linked command line documentation, especially --start-cpu-sampler and --snapshot-sampler, and reproduce the headless commands shown in the issue. Trace how sampling is started and stopped without DISPLAY, then define a command-line path that writes CPU or memory results to a snapshot file loadable in the VisualVM GUI.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
cli, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.