Java Virtual Machine Learning-Memory Optimization

Source: Internet
Author: User
Tags xms

JVM optimization mainly focuses on memory management optimization, including controlling the size of each generation and GC policy. The application thread is suspended when GC starts garbage collection, which seriously affects the performance. The purpose of optimization is to minimize the pause time of the Application Thread caused by GC and reduce the number of Full GC operations.
Generation Size Optimization
Key parameters:-Xms,-Xmx,-Xmn,-XX: Invalid vorratio,-XX: MaxTenuringThreshold,-XX: PermSize,-XX: MaxPermSize
-Xms and-Xmx are usually set to the same value to avoid continuous JVM memory expansion during runtime. This value determines the maximum memory that JVM heap can use.
-Xmn determines the size of the new generation space. The ratio of the New Generation Eden, S0, and S1 can be controlled through-XX: discounted vorratio (if the value is 4, Eden: S0: s1 =)
-XX: the number of times the MaxTenuringThreshold control object enters the old age after the minor GC. this parameter is only valid for Serial GC.
-XX: PermSize,-XX: MaxPermSize is used to control the size of the Method Area, usually set to the same value.
1. Avoid setting too small for the new generation.
When the young generation is set to an hour, there are two obvious phenomena: frequent minor GC times and direct minor GC objects to the old generation. When the memory in the old age is insufficient, Full GC is triggered.
2. Avoid setting too large for the new generation.
The setting of the new generation is too large, which may lead to two problems: first, the elderly become larger and smaller, which may lead to frequent Full GC execution, and second, the time for recovery of minor GC is greatly increased.
3. Avoid too large or too small vor zone.
-XX: the greater the value of the region vorratio parameter, it means that the Eden region is larger, the number of minor GC operations is reduced, but the two region vor regions become smaller, if objects that exceed the memory size of the region vor are not recycled after minor GC, they will enter the old age directly,
-XX: if the value of the interval vorratio parameter is set to be too small, it means that the Eden region becomes smaller, the number of minor GC triggers increases, and the interval vor region increases. This means that more objects can be stored after the minor GC, avoid entering the old age.
4. Reasonably set the lifetime cycle of the object in the new generation.
The survival cycle of the new generation determines how many times the new generation object enters the old age after Minor GC. Therefore, this value must be optimized based on your application. The Jvm parameter corresponds to-XX: MaxTenuringThreshold, which is 15 times by default.
GC Optimization
1. GC combination
See another Garbage Collector
2. View JVM Parameters
Command line tool visualization tool
3. GC Log Parameters
-XX: + PrintGCDetails
-XX: + PrintGCTimeStamps
-Xloggc: c: \ java \ gc. log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.