Frequently Asked Questions
about Garbage Collection
in the HotspotTM JavaTM Virtual Machine
- How is the generational collector implemented in HotSpot(tm)?
- What is the relevance of -XX:MaxNewSize? Where will the differences between -XX:NewSize and -XX:MaxNewSize grow, Eden or Survivor Spaces?
- Are all eden-space objects moved into the survivor space so that after a minor gc, eden-space is empty?
- When using -XX:TargetSurvivorRatio=90 will this leave ten percent of to-space for objects to be moved from eden?
- If objects in eden-space require more space than is available in the to-survivor space, will eden-space objects have precedence over from-survivor space objects? How does the age of from-survivor space objects affect promotion?
- Between NewSize and NewRatio which option takes precedence?
- How should the permanent generation be sized?
- How can I tell if the permanent generation is filling up?
- How can I increase the permanent generation size?
- How do I know what classes are being loaded or unloaded?
- What is the best size for the young generation?
- What should I do if my application has mid- or long-lived objects?
- When is a garbage collection started?
- What type of collection does a System.gc() do?
- What is the Concurrent Mark Sweep (CMS) collector?
- Why is fragmentation a potential problem for the concurrent low pause collector?
- What are the phases of the concurrent low pause collector?
- Does the VM allocate large int arrays for its own use?
- Can I see how much of a thread allocation buffer is being left unused?
- Does the default of NewRatio change with the compiler?
- What is the Parallel Garbage collector (-XX:+UseParallelGC)?
- What is the Parallel Young Generation collector (-XX:+UseParNewGC)?
- Which parallel collector should I use?
- Why is the startup with the concurrent low pause (CMS) collector slow?
- What young generation collector is used with concurrent low pause collector?
- Why does the low pause collector sometimes do more collections than the default collector?
- Are there other external sources for garbage collection documentation?
- With the concurrent low pause collector, what is a minimum value for NewRatio?
- Do objects ever get allocated directly into the old generation?
- If an allocation fails in the young generation and the object is a large array that does not contain any references to objects, it can be allocated directly into the old generation. In some select instances, this strategy was intended to avoid a collection of the young generation by allocating from the old generation.
- There is a flag (available in 1.4.2 and later) l-XX:PretenureSizeThreshold=<byte size> that can be set to limit the size of allocations in the young generation. Any allocation larger than this will not be attempted in the young generation and so will be allocated out of the old generation.
- Should I increase the size of the permanent generation in the client vm?
- Should I pool objects to help GC? Should I call System.gc() periodically?
- What determines when softly referenced objects are flushed?
- I'm getting lots of full garbage collections (GC's)when I turn on -verbose:gc. The GC's are at regular intervals. My application never calls System.gc. I've tuned the heap and it makes no difference, what's going on?
- The concurrent low pause collector seems to be doing full collections much of the time. How can the concurrent collection be sped up?
- Sometimes the concurrent low pause collector is about to finish the last part of a concurrent collection when a full collection starts. The full collection looks like it does the whole collection again. Can that happen?
- With the concurrent low pause collector how can I tell how much floating garbage is left?
- The parallel collectors seem to use as many garbage collector (GC) threads as there are processors on the machine. How can I ask for more or fewer GC threads?
- Why does fragmentation occur with the concurrent low pause collector?
- What options should be used with the throughput collector?
- What options should I use with the concurrent low pause collector?
#java -Xmx512m -Xms512m -XX:MaxNewSize=24m -XX:NewSize=24m -XX:+UseConcMarkSweepGC
java -Xmx512m -Xms512m -XX:MaxNewSize=24m -XX:NewSize=24m -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseConcMarkSweepGC
- What are the default settings for the concurrent low pause collector?
- What options should I use with the incremental low pause collector?