Making G1 decommit pages on idle?

Mike Hearn mike at plan99.net
Wed Sep 28 11:22:09 UTC 2016


Hi there,

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.

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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20160928/0f8bd181/attachment.html>


More information about the hotspot-gc-dev mailing list