开发者

How to increase the rate of GC calls in java?

开发者 https://www.devze.com 2023-03-25 06:32 出处:网络
How开发者_运维技巧 to increase the rate of GC calls in java? Are there any JVM parameters to tune the rate at which GC gets called?

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!!


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. -XpauseTarget should do this as a VM argument. Minimum value here is 10 milliseconds. Don't call System.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):

-Xincgc
-XX:+CMSIncrementalPacing
-XX:+UseAdaptiveSizePolicy
-XX:+AggressiveOpts
-XX:+ExplicitGCInvokesConcurrent
-XX:+UnlockExperimentalVMOptions
-XX:+UseConcMarkSweepGC
-XX:UseSSE=3
-XX:+UseParNewGC
-XX:SurvivorRatio=2
-XX:NewRatio=8
-XX:+DoEscapeAnalysis
-XX:+UseFastAccessorMethods
-XX:+ForceTimeHighResolution
-XX:+UseTLAB
-XX:+ResizeTLAB
-XX:MaxGCPauseMillis=10
-XX:ParallelGCThreads=8
-XX:+CMSParallelRemarkEnabled
-XX:+DisableExplicitGC
-XX:+UseAdaptiveGCBoundary
-XX:-UseGCOverheadLimit
-Xnoclassgc
-server
-Xss128k
-Xms1g
-Xmx1g
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号