How much do you understand jvm performance tuning

A, JVM tuning memory

The main purpose of system-level memory tuning the JVM is the number of Full GC and GC frequency reduction.

1.Full GC

Have a whole heap sort, including Young, Tenured and Perm. Full GC because of the need to recover the entire stack, so slow, so it should reduce the number of Full GC as possible.

2. The cause of Full GC

1) the old generation (a position of tenured) are filled

Try to make the object when tuning is recovered in the new generation of the GC, so that objects in the new generation of multi survive for some time and do not create too large objects and avoid creating an array of objects directly in the old generation.

2) lack of permanent generation space Pemanet Generation

Perm Gen increased space, avoid too much static objects, control the proportion of good old generation and the new generation

3) System.gc () call is displayed

Do not manually trigger garbage collection, as far as possible on their own mechanism JVM

In the process of tuning the JVM, a large part of the work for the adjustment is the FullGC, corresponding to the following detailed description JVM tuning methods and procedures.

Two, JVM and performance tuning method steps

1. Monitoring the status of GC

JVM using a variety of tools, view the current log, analyze the current JVM parameters, and analyze the current heap memory snapshots and gc log, based on the actual execution time of each memory division and regional GC, whether that be optimized.

As an example: some phenomena before the system crash:

  • Every time garbage collection more and more time will be extended from the previous 10ms to about 50ms, FullGC time there before 0.5s extended to 4,5s
  • Number FullGC more and more, most often after less than 1 minute once FullGC
  • Old generation memory and each time more and more old generation memory is not released after FullGC

After the system will be unable to respond to new requests, and gradually reach the critical value of OutOfMemoryError, this time on the need to analyze JVM memory snapshot dump.

2. Health piles of dump file

Generated by the JMX MBean Heap current information, the size of a 3G (whole heap size) of hprof file, if not start JMX can generate the file by the Java jmap command.

3. Analyze the dump file

Open this 3G heap information file, apparently Window System in general is not so much memory, requires the help of high-profile Linux, several tools to open the file:

  • Visual VM
  • IBM HeapAnalyzer
  • JDK comes Hprof tool
  • Mat (Eclipse specialized static memory analysis tool) is recommended

Note: The file is too large, it is recommended to use a special Eclipse static memory analysis tool Mat open the analysis.

4. The analysis result, determine the need to optimize

If you set reasonable parameters, the system does not log a timeout occurs, the frequency is not high GC, GC time-consuming is not high, so there is no need for optimization of GC, GC if more than 1-3 seconds, or frequent GC, it must be optimized.

Note: If the following indicators are met, the general does not require GC:

  • Minor GC execution time of less than 50ms;
  • Minor GC performed infrequently, for about 10 seconds;
  • Full GC execution time of less than 1s;
  • Full GC frequency is not performed frequently, not less than 10 minutes 1 second;

5. Adjust the GC and memory allocation type

If the memory allocation too large or too small, or the use of slow collector GC, these parameters should be adjusted with priority, and go first to a machine or several beta, and then comparing the machine and optimized performance is not optimized machine in contrast, targeted and make the final choice.

6. continuous analysis and adjustment

Through continuous testing and trial and error, analyze and find the most appropriate parameter, if the optimum parameters are found, these parameters apply to all servers.

Then I thought of jvm performance tuning very well, until I finish the interview Ali

 

Third, Ali jvm performance tuning face questions:

  • java class loading process
  • java memory allocation
  • Jvm describe the principle mechanism for loading class files?
  • GC is the What? Why should there be GC?
  • How to determine whether an object is alive?
  • Garbage collection advantages and principles. And consider two-recovery mechanisms.
  • java will be a memory leak it, please elaborate
  • Permanent with the JVM garbage collection will happen?
  • Java garbage collection method in which

Guess you like

Origin www.cnblogs.com/weigy/p/12399018.html