JAVA parsing heap Memory from GC log section Seventh
In the previous chapter, we only set the memory size of the entire heap. But we know that the heap is divided into the new generation, the old generation. How is the memory allocated between them? The new generation is also divided into Eden and survivor, can their proportions change? In fact, these are controllable, not previously mentioned because even if the talk is only to talk about, do not see the substantive things. So this chapter explains how to fine-tune the setup heap memory by analyzing the GC logs step by step.
First, let's look at a couple of related parameters:
-xx:+printgcdetails: Used to tell the virtual machine to recycle garbage while printing logs.
-XLOGGC: Path: Saves the printed log information to the specified path.
-XMN10M: Sets the memory size of the Cenozoic.
-xx:survivorratio=8: Adjust the ratio of Eden and survivor to 8:1
We still use yesterday's code example:
Then start with the parameter-xms20m-xmx20m-xmn10-xx:+printgcdetails-xloggc:d:\gc1.log. Represents allocating 20M to the heap, assigning 10M to the Cenozoic, printing the GC log, and outputting it to the D-disk Gc1.log file. After running, get the following log, which is the first part:
Now let's analyze the meaning of each part represented:
1) 0.090: The time that the virtual machine has gone from booting to the present.
2) GC: Refers to the type of pause (keep the next chapter)
3) Psyounggen: The area where the GC occurred, referring to the younger generation. Depends on the type of collector.
4) 7284k->1016k (9216K): The amount of capacity used in the current zone before GC (the total capacity of the region), that is, the capacity of the new generation.
5) 7284k->6139k (19456K): The capacity used by the current zone and the total capacity of the entire heap after GC before the entire heap.
6) 0.0078481: The time taken by this GC.
Let's take another look at the second part:
Look at the red section of the picture, indicating the current amount of available memory in the heap (a edenh and a survivor as available memory), the red box below the size of the old quarter, plus a total of 20m, in line with our set.
The red box is the new generation of Eden and two survivor area size, you can see their ratio is 8:1, if set to-xx:survivorratio=3, the result is as follows
To here the role of the above several parameters and analysis is finished, the small partners can open their own tools to try and feel about it. After encountering a memory leak or memory shortage, you can view the log directly to analyze tuning!
JAVA parsing heap Memory from GC log section Seventh