gpt4 book ai didi

java - Java G1 垃圾收集器是否尊重 MaxHeapFreeRatio 参数?

转载 作者:行者123 更新时间:2023-12-05 07:11:45 30 4
gpt4 key购买 nike

Java G1 垃圾收集器(在 Open JDK 中实现)是否遵守 -XX:MaxHeapFreeRatio=n JVM 参数?

它在 Java 8 中是否尊重它?

我找到了 JEP 346: Promptly Return Unused Committed Memory from G1在 Java 12 中交付,但我不清楚它之前的状态。

最佳答案

我找到的一个非权威答案是基于https://bugs.openjdk.java.net/browse/JDK-8078039?focusedCommentId=13632717&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13632717

Most notably, some GCs support it, some do not. This RFE doesn't say which GC is used, so I assume we are talking about the default GC which supports MaxHeapFreeRatio. G1 also supports this option.

To shrink the heap (and release memory) a full GC is required. It the application doesn't trigger a full GC manually, it may take a while before one is triggered by the JVM.

所以答案是(对于 Java 8):是的......但不是。

  • 是的,它支持该选项
  • 但只有当完全 GC 发生时,这可能永远不会发生

(我仍然很好奇在更现代的 JVM 中是否有更权威的来源以及当前状态)

关于java - Java G1 垃圾收集器是否尊重 MaxHeapFreeRatio 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60643928/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com