[Daily 3 minutes technological Dry | face questions + answers | jvm articles (a)]

1. What to say about the JVM garbage collection algorithm have?

  • Mark - sweep algorithms: mark useless objects, and then clear the recovery. Disadvantages: efficiency is not high enough to clear the garbage debris.

  • Mark - Collation Algorithm: mark useless objects, so that all live objects are moved to the end, and then clear out the memory directly outside the terminal boundary.

  • Replication algorithm: capacity divided according to the size of the memory area equal to two, when one runs out of copying live objects onto another piece of memory space has been used once and then clean out. Cons: memory usage is not high, only half of the original.

  • Generational algorithms: Depending on whom the survival period of the memory is divided into a few pieces, usually the new generation and the old era, the basic use of the new generation of replication algorithm, the use of tags to organize years old algorithm.

2. What to say about the JVM garbage collector?

  • Serial: The first single-threaded serial garbage collector.

  • Serial Old: Serial older version of the garbage collector, also a single-threaded, can be used as an alternative plan for CMS garbage collector.

  • ParNew: Serial is a multithreaded version of.

  • Parallel and similar ParNew collector is multi-threaded, but Parallel throughput is the priority of the collector, the waiting time can be sacrificed in exchange for system throughput.

  • Parallel Old version of the old generation is Parallel, Parallel garbage collection algorithm is used to copy, Parallel Old using the mark - finishing garbage collection algorithm.

  • CMS: one kind of the shortest pause time to obtain a target collector, ideal for B / S system.

  • G1: a balanced GC throughput and dwell time to achieve, is the default JDK 9 after GC options.

3. detail about CMS garbage collector?

CMS is the English abbreviation of Concurrent Mark-Sweep, at the expense of throughput at the cost of the minimum collection pause time garbage collector. For applications requiring the server response speed, which is very suitable for the garbage collector. In the JVM startup parameters plus "-XX: + UseConcMarkSweepGC" to specify the use of CMS garbage collector.

CMS using the mark - sweep algorithm to achieve, so a large amount of memory fragmentation in gc back to the time when the remaining memory can not meet the requirements of the program is running, the system will Concurrent Mode Failure occurs, the temporary CMS will use Serial Old collector garbage clearance, this time the performance will be reduced.

4. new generation and the old generation garbage collector garbage collector has what? ** What is the difference? **

  • New Generation collector: Serial, ParNew, Parallel Scavenge

  • Years old collector: Serial Old, Parallel Old, CMS

  • Whole stack collector: G1

New generation garbage collector copy algorithm is generally used, the advantages of replication algorithm is efficient, disadvantage is that memory utilization is low; year old collector is generally used to mark - sorting garbage collection algorithm.

5. Description of generational garbage collector is how to work?

Generational collector has two partitions: the old generation and the new generation, the new generation of 1/3 of the total space default spatial proportion, the proportion of the old generation of default is 2/3.

Using a new generation of replication algorithm, the new generation, there are three partitions: Eden, To Survivor, From Survivor, accounting for their default is 8: 1: 1, it performs the following process:

  • The Eden + From Survivor To Survivor live objects into regions;

  • Clear and Eden From Survivor partition;

  • From Survivor exchange and partition To Survivor, From Survivor variant To Survivor, To Survivor change From Survivor.

Each time From Survivor to move all live objects To Survivor age to +1, when reaching the age of 15 (15 is the default configuration), upgrade to the old generation. Large Objects also go directly to the old generation.

When the space occupied by the old generation reaches a certain value will trigger the recovery of the global garbage, general use tags to organize the execution of the algorithm. These constitute the overall implementation of the cycle processes across generational garbage collection.

6. talk about JVM tuning tool?

JDK comes with a lot of monitoring tools, are located in the bin directory of the JDK, the most commonly used is jvisualvm Both jconsole and view monitoring tools.

  • jconsole: the JVM for memory, threads and the like to monitor;

  • jvisualvm: JDK comes with the all-round analysis tool that can analyze: memory snapshots, snapshot thread, deadlock, monitoring changes in memory, gc change.

7. common JVM tuning parameters have what?

  • -Xms2g: Initialization push 2g size;

  • -Xmx2g: maximum heap memory is 2g;

  • -XX: NewRatio = 4: Set Memory proportions of young and old age is 1: 4;

  • -XX: SurvivorRatio = 8: Set the new generation Eden and Survivor ratio of 8: 2;

  • -XX: + UseParNewGC: Specifies ParNew + Serial Old garbage collector composition;

  • -XX: + UseParallelOldGC: Specifies ParNew + ParNew Old garbage collector composition;

  • -XX: + UseConcMarkSweepGC: Specifies CMS + Serial Old garbage collector composition;

  • -XX: + PrintGC: gc open print information;

  • -XX: + PrintGCDetails: Print gc details.

Epilogue

Take these words to encourage each other, encourage each other now. The more work, the more luck if you are not the official second-generation, rich second-generation, second generation red, remember: hard work is the only shortcut to change your destiny.

Feel free to leave your opinions in the comments section to discuss improving together. If today's article gives you new inspiration, new understanding to enhance the learning ability, welcome to forward share to more people.

Welcome to our readers to join programmer ** knowledge dock ** technology group , replies "No background in public plus group " can be.

[Daily 3 minutes technological Dry | face questions + answers | jvm articles (a)]

Guess you want to see

1. always ask interview jvm tuning in the end is going to do?

2. Programmers should have what kind of career planning? Worth thinking about!

[Daily 3 minutes technological Dry | face questions + answers | jvm articles (a)]

Guess you like

Origin blog.51cto.com/14626895/2464293