Why is garbage collector not doing a more aggressive garbage collection sooner than single digit heap free %?

痴心易碎 提交于 2019-12-21 05:31:12

问题


These are my Sun Hotspot 1.6 JVM heap settings in WebLogic 11g:

-Xms10g -Xmx10g -XX:MaxPermSize=256m -XX:+UseParNewGC -XX:ParallelGCThreads=2 -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:ConcGCThreads=2

What I'm seeing in the JVM heap free % graph for 24 hours is basically heap free % goes down at a slow rate until we hit about 9% (takes about 24 hours). Then the system is running what looks like a full gc and gets back to 97%.

Is there some setting I should add/modify that will tell the JVM to do this full GC sooner than when we get below 10% heap free? e.g. some ratio setting?

Its not causing problems that it waits until we get to 9% free, but it makes monitoring/alerting more difficult. Ideally we want to stay higher than say 30% free at all times so that if we drop down to those single digit numbers, we know there is some sort of problem e.g. memory leak.


回答1:


Found the answer using a combination of other stackoverflow articles.

-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=N

where N is roughly what percentage occupied will trigger a full GC. Default is ~92, which is why I am seeing full GC's at 9% free. Switching it to 65 worked for my use case. A full GC happens ~ 35% free now.




回答2:


How about removing: -Xms10g and then monitor the total size of the heap? This will also cause the gc to run more often.

If your app only really use 300MB of ram(3%), then it seems extreme to start with a 10 Gigabyte allocation.



来源:https://stackoverflow.com/questions/12842863/why-is-garbage-collector-not-doing-a-more-aggressive-garbage-collection-sooner-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!