Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,24 @@ This document is intended to familiarize the reader with the diagnostic tool tha

To begin, [download VisualVM](https://visualvm.github.io/download.html) and unpack it to the WPILib installation folder. The folder is located at ``~/wpilib/`` where ``~`` indicates the users home directory. On Windows, this is ``C:\Users\Public\wpilib``.

## Setting up Gradle
## Profiling Simulation

GradleRIO supports passing JVM launch arguments, and this is what is necessary to enable remote debugging. Remote debugging is a feature that allows a local machine (such as the user's desktop) to view important information about a remote target (in our case, a roboRIO). To begin, locate the ``frcJava`` code block located in the projects ``build.gradle``. Below is what is looks like.
When profiling simulation, no additional Gradle configuration is needed. VisualVM can directly connect to any Java process running on your computer, including robot simulations.

To profile simulation:

1. Launch VisualVM (see :ref:`Running VisualVM <docs/software/advanced-gradlerio/profiling-with-visualvm:Running VisualVM>` below for instructions)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it flows well to reference things down below that the user hasn't read yet. If simulation is the most common use case then build it into the instructions below, and then add the gradle instructions after that. Or alternately, move this section down below.

I can see arguments for either simulation or robot being the primary use case so I don't really care which one is moved down, but it seems convoluted the way it is now.

2. Start your robot simulation from VS Code
3. In VisualVM, the simulation process will automatically appear in the left sidebar under "Local" as a Java process
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having not done this, is it obvious what is the correct process to connect to? I could see it being likely that there's several java processes that show up between VS Code Java stuff, the robot code, gradle daemons, and wpilib tools.

4. Double-click the process to begin profiling

Once connected, you can use all the same features described in this document: CPU sampling, heap dumps, memory monitoring, and more.

.. tip:: You can also use the [VisualVM VSCode extension](https://marketplace.visualstudio.com/items?itemName=oracle-labs-graalvm.visualvm-vscode) for a more integrated experience.

## Setting up Gradle for roboRIO Profiling

GradleRIO supports passing JVM launch arguments, and this is what is necessary to enable remote debugging of code running on the roboRIO. Remote debugging is a feature that allows a local machine (such as the user's desktop) to view important information about a remote target (in our case, a roboRIO). To begin, locate the ``frcJava`` code block located in the projects ``build.gradle``. Below is what is looks like.

.. rli:: https://raw.githubusercontent.com/wpilibsuite/vscode-wpilib/v2025.3.1/vscode-wpilib/resources/gradle/java/build.gradle
:language: groovy
Expand Down