调整G1GC参数以进行积极的垃圾收集吗? [英] Tuning G1GC params for aggressive garbage collection?

查看:141
本文介绍了调整G1GC参数以进行积极的垃圾收集吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的JVM基本上是一个火花执行器,它一个接一个地运行任务.一项任务非常耗内存,并且在其生命周期中需要大量内存.

My JVM is basically a spark executor which is running tasks one after another. A task is memory hungry and requires significant memory during its lifecycle.

JConsole和JVisualVM并排报告

以上JVM在带有默认参数的G1GC上运行.正如您在右侧4:25到4:32 PM之间的VisualVM报告中所看到的,峰值是由于执行者运行的每个任务引起的(本质上,每个峰值都是由于执行者在执行任务之后选择了新任务而造成的).前一个已完成).当我在4:35触发手动GC时,我看到堆使用量急剧下降.另外,正如您在JConsole报告的左侧所看到的那样,G1GC从未收集过旧基因世代空间(16:35之前的旧基因世代空间急剧下降是由于手动GC).

因为我的应用程序是一个批处理作业应用程序,所以如果JVM花大量时间进行GC,我可以.但是,我的内存不足.因此,我想知道如何调整JVM G1GC参数,以便有更频繁的GC(也收集了旧的Gen空间),并且可以用更少的堆空间(XMX)来完成工作.

The above JVM is running on G1GC with default params. As you can see in the VisualVM report on the right hand side between 4:25 to 4:32 PM, the spikes are due to each tasks run by the executor (essentially, each spike is due to the executor picking up new task after the previous one is finished). When I triggered a manual GC at 4:35, I saw a sharp decline the heap usage. Also, as you can see on the left hand side in the JConsole report, the old gen space is never collected by G1GC (the sharp decline in old gen space just before 16:35 is due to the manual GC).

As my application is a spark batch job application, I am ok if the JVMs spent good amount of time doing GC. But, I am running bit short on memory. So, I wanted to know how I can tune my JVM G1GC params so that there are more frequent GC (with the old gen space also getting collected) and I can get the work done with considerably lesses heap space (XMX).

推荐答案

对于G1,OpenJDK 12功能是迅速将未使用的内存返回给操作系统:

For G1, promptly returning unused memory to the operating system is an OpenJDK 12 feature:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆