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.
|
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.
|