<div dir="ltr">Hi there,<div><br></div><div>In Java 9 the default GC will become G1 rather than the throughput collector. This has potential to be nice on desktops due to lower pause times, but can at the moment easily be worse because G1 "never" releases memory regions back to the OS unless there's a full GC, which is supposed to be a last resort option. I routinely discover that idle Java processes like Gradle daemons are wasting >50% of their heap doing nothing. I believe that on Windows, the JVM may try to more aggressively release memory back to the OS but I see no evidence of this on MacOS X.</div><div><br></div><div>Java has over the years obtained a reputation for being a memory pig. Java 9 has some optimisations to improve that, like the excellent compressed strings work, but it's all for nothing if the saved memory is pointlessly held on to just in case it's about to be used again.</div><div><br></div><div>How feasible is it for G1 to notice when the app appears to be idle and start scheduling minor collections with consequent region decommits? I looked at the G1 source on a recent flight and it didn't look hugely difficult, with the trickiest part being a good estimation of what "idle" is (perhaps - no allocations for several seconds). But I don't know if there are some tricky details that'd prevent such a feature being accepted .... like the feature freeze. It'd be a shame if Java 9 shipped without taking the chance of changing its reputation for heavy memory usage.</div></div>