RuntimePermission for explicit GC

Pratik Solanki pratik.solanki at gmail.com
Tue Jan 15 19:12:33 UTC 2008


You could pass -XX:+DisableExplicitGC to change System.gc() to a no- 
op. It'll just return without doing anything. This should work in 1.5  
and 1.6.

Pratik

On Jan 12, 2008, at 1:04 PM, Raman Gupta wrote:

> 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