United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6974928 G1: sometimes humongous objects are allocated in young regions
JDK-6974928 : G1: sometimes humongous objects are allocated in young regions

Details
Type:
Bug
Submit Date:
2010-08-05
Status:
Closed
Updated Date:
2011-04-23
Project Name:
JDK
Resolved Date:
2011-04-23
Component:
hotspot
OS:
generic
Sub-Component:
gc
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
hs19
Fixed Versions:
hs19 (b06)

Related Reports
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
During testing some other changes, I came across a case where humongous objects were being allocated on young regions and copied during collection pauses. This breaks the fundamental G1 assumption that humongous objects are always allocated separately. I've only seen this when running dacapo pmd.

                                    

Comments
SUGGESTED FIX

The fix is straightforward, in attempt_allocation() only attempt to allocate into the current alloc region if the allocation request is not humongous. If it is, we'll go to the attempt_allocation_slow() method which will allocate the humongous object correctly.
                                     
2010-08-05
EVALUATION

The reason for this was that mem_allocate was being called directly from runtime / interpreter to allocate an array. mem_allocate in turn called attempt_allocation():

inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size,
                                              bool permit_collection_pause) {
  ...
  if (_cur_alloc_region != NULL) {
    // If this allocation causes a region to become non empty,
    // then we need to update our free_regions count.

    res = _cur_alloc_region->allocate(word_size);
  }
  ...
  return attempt_allocation_slow(word_size, permit_collection_pause);
}

attempt_allocation() first tries to allocate the object in the current alloc region. If it happens that there's still space in that region (this can happen if the humongous object size is smaller than the region size and larger than the humongous size threshold, currently being region size / 2), the allocation would go ahead, even if the region is young.
                                     
2010-08-05
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/bb847e31b836
                                     
2010-08-17



Hardware and Software, Engineered to Work Together