Java G1 GC Processing Reference objects works slow

前端 未结 2 1205
傲寒
傲寒 2021-02-08 05:59

I have hit counter running on Java. It works 24 hours and hits pass at about 100 times per second. During the day GC processing time slowly rises from 20-60 ms till 10000-60000

2条回答
  •  情深已故
    2021-02-08 06:30

    As a first step you can use VisualVM or any tool to analyze your heap usage pattern. You might have a solution by optimising your code, by checking hotspots of object creation and that should be a permanant solution.

    If that is not possible you have to find the optimal heap size and a GC algorithm suiting your applications behaviour. This is going to be a trial and error method. You will definitly have to go through tuning doc. The tuning you do now might again become inefficient later when your application behaviour changes or load pattern changes.

    Try and find the suitable collector for you. You will be tweaking some parameters like

        -XX:+UseConcMarkSweepGC        
        -XX:SurvivorRatio=10 
        -XX:TargetSurvivorRatio=90 
        -XX:MaxTenuringThreshold=30
    

    by trial and error.

提交回复
热议问题