Java Virtual Machine tuning knowledge

Source: Internet
Author: User

There are no tips for JVM adjustment. There are only some principles. You need to set the optimization goal based on the characteristics of your application. Here we collect some content and choose to record it.

 

Java heap (xmx, XMS) and Java Process heap are two different situations.

The heap of the Java Process includes:

Java heap

Permanent generation

Thread stacks

Native code

Directly allocated memory

Code Generation

Garbage Collection

TCP Buffers

Therefore, we should be careful when setting JVM parameters. Generally, we will set Java heap and perm Gen to select a reasonable value based on the memory size and application characteristics of the operating system. -XMS/-xmxjava heap is not as large as possible, but its general optimization principle is sufficient. If it is too large, the memory will be wasted, at the same time, GC efficiency is affected-XX: newsize/-XX: newratio is generally set to 25%-33% of Java heap, which is too large or too small will affect GC. According to the characteristics of the application, to adjust the GC-related adjustment objectives, the ratio of object life cycle is as follows: * Do not enter the old area for short-lived objects * short-lived objects are killed during minor GC * long-lived objects must be placed in the old area * long-lived objects can be full GC cleaning, however, the full GC should be adjusted to the minimum possible occurrence. No matter what algorithm is used, GC will always cause the application to be paused. The duration ranges from milliseconds to seconds, which will affect the corresponding time of the application, the duration of the pause depends on the characteristics of the application. You can adjust it by setting the GC pause time (note that it is only the expected time, not the absolute time)-XX: maxgcpausemillis-XX: maxgcminorpausemillis, generally, setting a short pause will lead to a relatively frequent GC, which can be adjusted based on the application situation.

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.