[英]Default garbage collector for Java 8
What is the default garbage collector for Java 8? Java 8 的默认垃圾收集器是什么?
When I check the JMX Beans, they reveal it to be the parallel collector for the new generation and the old serial collector for the old generation.当我检查 JMX Beans 时,他们发现它是新一代的并行收集器和老一代的旧串行收集器。
Default garbage collectors:默认垃圾收集器:
Selecting the default garbage collector (among other things) is what's called the ergonomics process of the JVM.选择默认的垃圾收集器(除其他外)就是所谓的 JVM 的人体工程学过程。 This process depends on the class of your machine.
此过程取决于您的机器类别。
Since practically all machines have 2 or more CPU, a machine is practically always considered server-class by the JVM.由于几乎所有机器都有 2 个或更多 CPU,因此 JVM 实际上总是将机器视为服务器级。 That's why you will find a lot of references considering the parallel collector to be the default garbage collector.
这就是为什么您会发现很多参考资料都将并行收集器视为默认垃圾收集器。
Java has four types of garbage collectors(Up to version 10),but after stable release of java 11 , it would be 5 types. Java有四种类型的垃圾收集器(直到版本10),但是在Java 11稳定发布后,它将是5种类型。 These are:-
这些是:-
S GC
S GC
P GC
P GC
CMS GC
CMS GC
G1 GC
G1 GC
ZGC
ZGC
Default implementations of GC in java - java中GC的默认实现 -
JVM GC
JVM 垃圾回收
Java 7 - P GC Java 8 - P GC Java 9 - G1 GC Java 10- G1 GC Java 11- Z GC(I am not sure but it would be default GC of java 11)
More details for ZGC,please visit ZGC的更多详细信息,请访问
http://openjdk.java.net/projects/zgc/ http://openjdk.java.net/projects/zgc/
https://www.opsian.com/blog/javas-new-zgc-is-very-exciting/ https://www.opsian.com/blog/javas-new-zgc-is-very-exciting/
Note: If you want to verify, which GC is currently being used by JVM,you can go for following command to show default GC:-注意:如果要验证JVM当前正在使用哪个GC,可以执行以下命令以显示默认GC:-
$ java -XX:+PrintCommandLineFlags -version
If you want to set GC according to your need, you can do this by following command.如果您想根据需要设置 GC,可以通过以下命令进行。 Here I am going to set G1 GC as default GC.
这里我将 G1 GC 设置为默认 GC。
$ java -XX:+UseG1GC -XX:+PrintCommandLineFlags -version
For more details , please visit
https://javapapers.com/java/types-of-java-garbage-collectors/ https://javapapers.com/java/types-of-java-garbage-collectors/
https://alvinalexander.com/java/java-jvm-how-show-which-garbage-collector-running https://alvinalexander.com/java/java-jvm-how-show-which-garbage-collector-running
从 Java 9 到 Java 15,G1GC 是默认设置,即使在 Java 15 上也是默认的,它增加了两个新一代垃圾收集器,甲骨文开发的 ZGC 和红帽实现,即雪兰多,两者都在 2020 年 9 月的 Java 15 中投入生产。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.