简体   繁体   中英

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

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.

A slow full GC (and minor GC for that matter) is primary a result of a poor hardware setup and secondly software configuration (ie 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 ie 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, ie 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM