RuntimePermission for explicit GC
Raman Gupta
rocketraman at fastmail.fm
Tue Jan 15 19:33:39 UTC 2008
Pratik Solanki wrote:
> 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
>
> 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.
I'm aware of that... I think you missed my first sentence where I
stated that I want to explicitly execute GCs during off-hours.
Disabling explicit GCs entirely would conflict with that goal :-)
Cheers,
Raman Gupta
More information about the hotspot-gc-dev
mailing list