How to increase the rate of GC calls in java? Are there any JVM parameters to tune the rate at which GC gets called?
Thanks!!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you change the GC pause time, garbage collection should take place more frequently. This may be useful for some time critical apps where you need garbage collections to not take as long as it might, even if there may be more collections.
-XpauseTargetshould do this as a VM argument. Minimum value here is 10 milliseconds. Don’t callSystem.gc(). Depending on where you call it, you could make your application hugely inefficient.The best idea is to simply optimise your application to use fewer objects. You can use a tool such as JVisualVM which comes with the JDK to inspect your app at runtime and find out where the problem lies, and also to look at the garbage collection info.
You could also try a different garbage collector. I use the following, and it helps me in some applications where memory usage, say, is more important than CPU time (although there’s a few useless options here — just weed them out):