RuntimePermission for explicit GC

Raman Gupta rocketraman at fastmail.fm
Sat Jan 12 21:04:22 UTC 2008


The new -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses flag in JDK
1.6.0_04 reminds me of some behaviour that I'd like to see in future
java versions.

This flag is useful for an application to schedule GCs during
off-hours, but what if my application imports libraries that
internally have calls to System.gc()? Thankfully, this is becoming
rarer, but it would be nice if System.gc() internally checked a new
RuntimePermission "executeExplicitGc", and simply returned without
taking any action if that permission was not granted to the calling
code. If this was implemented, perhaps the signature could be changed
to return a boolean if the collection was successfully scheduled?

Cheers,
Raman Gupta



More information about the hotspot-gc-dev mailing list