1

I'm trying to analyse memory leak using java mission control, I wanted to find the reference to the classes from which the object are getting created, looks like I have to enable the below properties to get that details from Live Object details, but I'm unable to find this settings or not sure from where I should enable this, can anyone help me here?

"Before starting a flight recording, make sure that the option Object Types + Allocation Stack Traces + Path to GC Root is selected from the Memory Leak Detection setting."

below live objects is coming as empty so unable to find which class is responsible for creating the objects that are there in memory

enter image description here

Vignesh
  • 91
  • 7

1 Answers1

3

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:

  1. 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.

  2. 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
  1. 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
Kire Haglin
  • 6,569
  • 22
  • 27