Check heap usage with Java Flight Recorder

What I wanted to do was to use jcmd to get the jfr file on the web application server and check the heap usage status on jmc on my development PC (Windows).

Basic information

Conclusion (where it took time to resolve)

In order to record heap usage data in the jfr file, it is necessary to modify the profile and pass it as the settings parameter of jcmd. (It took me a long time to get there, probably because I wasn't looking for it.)

procedure

1. 1. Profile modification

Two types of profiles are stored below.

$ cd [JDK_PATH]/jre/lib/jfr
$ ll
-rw-r--r--1 root root 20109 October 6 22:55 default.jfc
-rw-r--r--1 root root 20065 October 6 22:55 profile.jfc

Copy profile.jfc (myProfile.jfc) and enable the part of the heap that seems to be related to data recording. I'm not sure if this is correct because I couldn't find a reference around here. (But it works.)

<!--From false to true around line 127-->
<flag name="heap-statistics-enabled" label="Heap Statistics">true</flag>

<!--From false to true around line 268-->
    <event path="vm/gc/detailed/object_count">
      <setting name="enabled" control="heap-statistics-enabled">true</setting>
      <setting name="period">everyChunk</setting>
    </event>

2. Get jfr file

I will omit the detailed information, but the point is to specify the profile created earlier with the settings parameter.

jcmd [PID] JFR.start name=MyJfrRec settings=myProfile maxsize=100mb dumponexit=true filename=/tmp/myJfrRec.jfr

Check the recording status

jcmd [PID] JFR.check

Dump of recorded information

jcmd [PID] JFR.dump name=MyJfrRec filename=/tmp/mytasrec.jfr

End of recording

jcmd [PID] JFR.stop name=MyJfrRec

After that, if you load the acquired jfr file into jmc, the graph will come out with a good feeling.

[Site that I referred to] http://waysaku.hatenablog.com/entry/2014/07/22/005304 https://blogs.oracle.com/poonam/clarifying-some-confusion-around-java-flight-recordings

We are looking for engineers. I hope you can see this as well. https://www.nittsu-infosys.com/recruit/2019/index.html

Recommended Posts

Check heap usage with Java Flight Recorder
Troubleshooting with Java Flight Recorder
Run analysis with OpenJDK11 Java Flight Recorder + Google Kubernetes Engine
[Java 8] Duplicate deletion (& duplicate check) with Stream
I checked Java Flight Recorder (JFR)
[Java] Element existence check with Stream
Java version check
OpenJDK 11 Flight Recorder
Java check process
Check the behavior of Java Intrinsic Locks with bpftrace
Check coverage with Codecov in Java + Gradle + Wercker configuration
Install java with Homebrew
Check Java toString () implementation
Change seats with java
Install Java with Ansible
Comfortable download with JAVA
Regarding Java variable usage
Switch java with direnv
Download Java with Ansible
Let's scrape with Java! !!
Build Java with Wercker
Endian conversion with JAVA
[Java] Check the difference between orElse and orElseGet with IntStream
[Maven] Disable .Net-based Assembly Analyzer with OWASP Dependency Check [Java]