从G1GC移动时,ZGC失踪错误
我有一个 Java 17 中的应用程序,配置如下:
-Xms4096m -Xmx4096m -XX:+UseG1GC -XX:MaxMetaspaceSize=1024m
这是一个相当大的 Web 服务,多年来非常占用内存,它是从其他服务使用的基线:
-Xms1024m -Xmx1024m -XX:+UseG1GC -XX:MaxMetaspaceSize=128m
我已经开始在我们公司的 Web 服务上试用 ZGC,以尝试从我们的服务中获得更多的性能,因此我切换了一些看起来表现良好的基准服务:
-Xms1024m -Xmx1024m -XX:+UseZGC -XX:MaxMetaspaceSize=128m
但是当我去尝试 ZGC 上的单个大型服务时,我遇到了一个错误:
-Xms4096m -Xmx4096m -XX:+UseZGC -XX:MaxMetaspaceSize=1024m
结果:
Apr 4, 2022 @ 15:06:22.103 Error: Could not create the Java Virtual Machine.
Apr 4, 2022 @ 15:06:22.026 [0.983s][error][gc] Failed to allocate initial Java heap (4096M)
Apr 4, 2022 @ 15:06:21.952 [0.966s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:21.881 [0.983s][error][gc] Forced to lower max Java heap size from 4096M(100%) to 3366M(82%)
Apr 4, 2022 @ 15:06:21.826 [0.982s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:21.826 Error: A fatal exception has occurred. Program will exit.
Apr 4, 2022 @ 15:06:21.783 [0.934s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:21.226 [0.979s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:20.224 [0.591s][error][gc] Failed to commit memory (Not enough space)
我注意到在他们的一个测试中记录了类似的 JDK 问题 这里 虽然我不是使用 -XX:+UseLargePages
我相信这意味着与 G1GC 相比,我没有在堆中留下足够的空间来让 ZGC 启动。我肯定想在更大的服务中使用 ZGC,因为我觉得那里的收益最大;但ZGC还很新,我在搜索过程中还没有找到很多关于它的信息。使用 ZGC 的标志中合适的值/比率是多少?是否有关于何时使用 ZGC 而不是 Shenandoah 或 G1GC 的官方建议?
I have an application in Java 17 configured like so:
-Xms4096m -Xmx4096m -XX:+UseG1GC -XX:MaxMetaspaceSize=1024m
It's a rather large web service that is pretty memory intensive over the years that's grown from a baseline other services use:
-Xms1024m -Xmx1024m -XX:+UseG1GC -XX:MaxMetaspaceSize=128m
I've started to trial ZGC in our company on our web services to try and get a little bit more performance out of our services so I switched some of our baseline services which seemed to perform fine:
-Xms1024m -Xmx1024m -XX:+UseZGC -XX:MaxMetaspaceSize=128m
but when I went to try our single large service on ZGC I run into an error:
-Xms4096m -Xmx4096m -XX:+UseZGC -XX:MaxMetaspaceSize=1024m
Results in:
Apr 4, 2022 @ 15:06:22.103 Error: Could not create the Java Virtual Machine.
Apr 4, 2022 @ 15:06:22.026 [0.983s][error][gc] Failed to allocate initial Java heap (4096M)
Apr 4, 2022 @ 15:06:21.952 [0.966s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:21.881 [0.983s][error][gc] Forced to lower max Java heap size from 4096M(100%) to 3366M(82%)
Apr 4, 2022 @ 15:06:21.826 [0.982s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:21.826 Error: A fatal exception has occurred. Program will exit.
Apr 4, 2022 @ 15:06:21.783 [0.934s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:21.226 [0.979s][error][gc] Failed to commit memory (Not enough space)
Apr 4, 2022 @ 15:06:20.224 [0.591s][error][gc] Failed to commit memory (Not enough space)
I noticed that there was a similar JDK issue logged on one of their tests here and although I'm not using the -XX:+UseLargePages
I believe the implication is that I'm not leaving enough space in the heap to let ZGC start up compared to G1GC. I'd definitely like to use ZGC in the bigger service as I feel like there's the most gain there; but ZGC is new enough that I haven't found a lot of information on it during my search. What are the appropriate values/ratios in the flags for utilizing ZGC? Are there official recommendations on when to use ZGC over Shenandoah or G1GC?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论