JMC options, such as "Object Types + Allocation Stack Traces + Path to GC Root", can be set on command line from JDK 17:
memory-leaks=<off|types|stack-traces|gc-roots>
For example:
$ java -XX:StartFlightRecording:memory-leaks=gc-roots
$ jcmd <pid> JFR.start memory-leaks=gc-roots
For release prior to JDK 17, there are three ways:
In JMC, right-click on the application and choose "Start Flight Recording" in the JVM Browser. On the second page in the recording wizard, select "Object Types + Allocation Stack Traces + Path to GC Root" from the "Memory Leak Detection setting" and click finish to start the recording.
If you are starting the recording from the shell, select Window -> "Flight Recording Template Manager" in the JMC top menu, duplicate the configuration and click Edit. make sure "Object Types + Allocation Stack Traces + Path to GC Root" is selected from the "Memory Leak Detection setting" and export the configuration file. Then you can use the file like this.
$ java -XX:StartFlightRecording:settings=custom.jfc ...
On an already running instance:
$ jcmd <pid> JFR.start settings=custom.jfc
The third way, and perhaps easiest, is to use the profile template to enable allocation stack trace and set the path-to-gc-roots option directly:
$ java -XX:StartFlightRecording:settings=profile,path-to-gc-roots=true ...
On an already running instance:
$ jcmd <pid> JFR.start settings=profile path-to-gc-roots=true