简体   繁体   English

Java虚拟机如何决定使用哪种垃圾回收方法?

[英]How does the Java virtual machine decide which method of garbage collection to use?

I have read a few articles describing how the Java virtual machine uses different techniques for collecting garbage. 我已经阅读了几篇文章,描述了Java虚拟机如何使用不同的技术来收集垃圾。

How does the Java virtual machine decide which method of garbage collection to use? Java虚拟机如何决定使用哪种垃圾回收方法?

Or, if the decision rests on the programmer, what constitutes changing the method of garbage collection? 或者,如果决定权在程序员身上,那么改变垃圾收集方法的构成是什么?

Thank you. 谢谢。

(Example of one article: https://www.javaworld.com/article/2078645/java-se/jvm-performance-optimization-part-3-garbage-collection.html ) (一篇文章的示例: https : //www.javaworld.com/article/2078645/java-se/jvm-performance-optimization-part-3-garbage-collection.html

You can specify which GC collector to use via jvm options. 您可以通过jvm选项指定要使用的GC收集器。 Checkout that link: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/collectors.html 签出该链接: https : //docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/collectors.html

It contains various information about how to choose a particular collector. 它包含有关如何选择特定收集器的各种信息。

Also you can see this answer to see which collector your jvm uses: find which type of garbage collector is running 您还可以看到以下答案,以查看您的jvm使用哪个收集器: 查找正在运行哪种类型的垃圾收集器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM