Why will a full gc on small heap takes 5 seconds?

牧云@^-^@ 提交于 2019-12-23 05:33:16

问题


I am running an J2EE application on 3 year old Solaris system with a used heap that is about 300 MB. From the gc logs I have seen that the full gc that is triggered a few times a day takes about 5 seconds and recovers about 200 MB every time. What could be the reason for a full gc to take such a long time on such a small heap?

I run java 1.6.0_37.


回答1:


A slow full GC (and minor GC for that matter) is primary a result of a poor hardware setup and secondly software configuration (i.e. GC ergonomics), and at last the number of object residing in the heap.

Looking at the hardware, what CPU model and vendor are you using on your Solaris? Is it a SMP system with more than one core. Do you have more than one thread per core? Do your GC utilize all available virtual processors on the system i.e. is the garbage collection distributed across more than one processor?

Another situation making full GC to perform slow is if a part of the heap is swapped out from main memory. In that case the memory pages swapped out must be swapped in during the garbage collection which can be a rather time consuming process. In that case you do not have sufficient physical memory installed on the machine.

Does any other applications on the system compete for the same physical resources, i.e. CPU and memory?

Looking at the GC ergonomics, what collector are you using? I would recommend the parallel throughput collector or the G1 collector using multiple collector threads. I would also recommend to use a NUMA configuration.

Some general rules:

  • The better hardware and GC ergonomics, the faster the individual garbage collections will perform.
  • The fewer and smaller objects the application creates, the less often will the garbage collector run.
  • The fewer long lived object created, the less often will the full garbage collector run.

For more information about GC ergonomics: http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html



来源:https://stackoverflow.com/questions/18399962/why-will-a-full-gc-on-small-heap-takes-5-seconds

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