How to do force full garbage collection when heap usage goes beyond a certain threshold

Leo Korinth leo.korinth at oracle.com
Mon Feb 24 13:42:02 UTC 2020


Hi Mohd,

You probably do not want to force a a full gc with g1. G1 is designed so 
that you should be abled to do young/mixed collections and never have to 
do a full one.

Your probably ought to be on running a full gc as few times as possible. 
Forcing premature full collections will probably add latency, reduce 
throughput and mess with valuable statistics for meeting deadlines. 
Also, before Java 10, full gc for g1 was single threaded.

If you still have a good use case for it after this warning, you might 
want to weaken the explicit gc by making it a concurrent one 
(-XX:+ExplicitGCInvokesConcurrent).

What underlying problem is it you are trying to solve? Maybe it can be 
solved by other means?

Thanks,
Leo


On 24/02/2020 08:45, mohd shaban wrote:
> Hi Team,
> 
> Is there a way to force GC when heap usage goes beyond a certain threshold?.
> I am using G1GC Algorithm.
> 
> Thanks,
> Mohd Shaban
> 
> _______________________________________________
> hotspot-gc-use mailing list
> hotspot-gc-use at openjdk.java.net
> https://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use
> 


More information about the hotspot-gc-use mailing list