Java memory management and how to read GC Viewer

This is a log when I investigated an application that was killed by OOM Killer due to lack of memory in the JVM. I used GC Viewer to check the GC log file to see the transition of memory usage.

Before that, I also reorganized the outline of Java memory management, so I have described it.

Java Memory Management Overview

A prerequisite knowledge of Java memory management is required to view GC Viewer.

This article was very helpful. Thank you very much. http://qiita.com/opengl-8080/items/64152ee9965441f7667b

java memory A very rough diagram showing the memory structure. Largely, there are two areas, a heap area and a native area. The heap is an area used by Java programs, and objects created on the program are placed in this heap area. On the other hand, the native area is used to manage the stack of memory and threads needed for the JVM to run.

(Source: http://qiita.com/opengl-8080/items/64152ee9965441f7667b#java-%E3%81%AE%E3%83%A1%E3%83%A2%E3%83%AA%E7%AE% A1% E7% 90% 86)

From the above, you can see that there are Young (New) and Old (Tenurd) in the heap.

The flow of GC seems to be as follows.

--The newly created object is saved in the Eden area of the Young area. --When Eden is full, the GC in the New area (called Scavenger GC, which is executed frequently) runs, and the objects that are not destroyed here are moved from Eden to the Survivor area. --The next time the Scavenger GC runs, the movement from Eden to Survivor is the same, and objects that were in the Survivor area that were not destroyed are moved to the other Survivor area. --Repeat this, and when the number of transfers exceeds the threshold, the object will be moved to the Old area. --Full GC runs when the Old area is full, but this takes a long time to process, so this number should be reduced.

Reference page

http://qiita.com/taisho6339/items/a6a7954bd473e16706bd http://blog.pepese.com/entry/20120508/1336467306 http://www.whitemark.co.jp/tec/java/javagc.html

Based on the above, try using GC Viewer

https://github.com/chewiebug/GCViewer/wiki/Changelog The above is the URL for downloading the application.

How to use

Simply open the downloaded application and drag and drop the GC log file. It was easy.

View

Screen Shot 2017-08-30 at 16.22.44.png

At first, many lines and areas are displayed, but I narrowed down to only the necessary ones from the View settings. The displayed area and destination are as follows.

--Pink is the Old area --Yellow is the Young area --The pink line inside the pink is the heap usage of the Old area. --The gray line in yellow is the heap usage of the New area. --The blue line is the total heap area usage --The black line is when FullGC runs

From the above, it can be inferred that OOM Killer ran due to lack of memory in the area where the black lines on the far right are dense.

bonus

This is the output of GC Viewer after increasing the memory.

Screen Shot 2017-08-30 at 19.30.06.png

It was stable.

that's all.

Recommended Posts

Java memory management and how to read GC Viewer
How to use GC Viewer
[Java] How to output and write files!
[Java] How to get and output standard input
How to get and study java SE8 Gold
How to access Java Private methods and fields
[Java] How to use Calendar class and Date class
<java> Read Zip file and convert directly to string
[Java] Types of comments and how to write them
How to convert A to a and a to A using AND and OR in Java
[Java] How to use Map
[Java] How to use Map
How to uninstall Java 8 (Mac)
Java --How to make JTable
How to use java Optional
How to minimize Java images
How to write java comments
How to use java class
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to display Wingdings
[Java] How to use string.format
How to use Java Map
How to set Java constants
How to use Java variables
[iOS] How to read Carthage
How to convert Java radix
[Java] How to implement multithreading
[Java] How to use Optional ①
How to initialize Java array
How to read your own YAML file (*****. Yml) in Java
Java conditional branching: How to create and study switch statements
Difference between Java and JavaScript (how to find the average)
What happened in "Java 8 to Java 11" and how to build an environment
How to call and use API in Java (Spring Boot)
How to write and notes when migrating from VB to JAVA
How to develop and register a Sota app in Java
Differences in how to handle strings between Java and Perl
How to use StringBurrer and Arrays.toString.
How to study Java Silver SE 8
How to use Java HttpClient (Get)
Studying Java # 6 (How to write blocks)
[Java] How to update Java on Windows
How to make a Java container
How to disassemble Java class files
How to use Java HttpClient (Post)
[Java] How to use join method
About TestSize advocated by Google and how to realize TestSize by Java and Maven
Basics of Java development ~ How to write programs (variables and types) ~
How to learn JAVA in 7 days
How to call classes and methods
[Java] How to use static modifiers (What are static final and static import)
How to use equality and equality (how to use equals)
[Processing × Java] How to use variables
[Java] How to create a folder
How to read a file and treat it as standard input
How to connect Heroku and Sequel
How to decompile java class files
[Java] How to use LinkedHashMap class
How to convert LocalDate and Timestamp
[JavaFX] [Java8] How to use GridPane