Currently, in G1 large objects are objects that cover half of a region. This is a problem in tight heaps with many large objects.
This is not optimal for the following reasons:
- lots of waste, up to 50% of region size
- programmers tend to size arrays in power of two chunks (and the default strategy when increasing buffer sizes is by doubling it), which results in many (array) objects that are just beyond this threshold
- G1 does not do a lot to keep large objects under control regarding placement, leading to fragmentation
- currently the only option to decrease the number of large objects in the heap is to increase the heap region size. In smaller heaps this is not a good solution, as this decreases the number of regions, limiting the flexibility of the G1 collector. Also this method puts the burden on the copying collector as it needs to copy more object data.
Investigate the effect of slightly increasing this threshold, and making it available using an experimental option.
Investigate further ideas in that direction, e.g. automatic threshold adapation, and/or making this setting dynamically adjustable.