Request for review: JDK-8009561 NPG: Metaspace fragmentation when retiring a Metachunk

Jon Masamitsu jon.masamitsu at
Thu Jun 6 02:41:01 UTC 2013

On 6/5/2013 7:04 AM, Mikael Gerdin wrote:
> Hi,
> Can I have some reviews of this small fix to the Metaspace memory 
> allocation path.
> Problem:
> When a Metaspace allocation request cannot be satisfied by the current 
> chunk the chunk is retired and a new chunk is requested. This causes 
> whatever is left in the chunk to be effectively leaked.
> Suggested fix:
> Put the remaining memory in each chunk on the Metablock freelist so it 
> can be used to satisfy future allocations.
> Possible addition:
> When allocating from the block free list, use 
> FreeBlockDictionary<Metablock>::atLeast instead of 
> FreeBlockDictionary<Metablock>::exactly and split the Metablock if 
> it's large enough.
> One might argue that this increases the fragmentation of the memory on 
> the block free list but I think that we primarily want to use the 
> block free list for small allocations and allocate from chunks for 
> large allocations.
> Webrev:
> Only fix:

The "Only fix" looks good.  Did you test with metaspace_slow_verify=true?

> Incremental webrev for splitting blocks:

Change looks good.

Did you do any long running tests with the block splitting?  Such as
24hours with kitchensink?  Something that would reuse Metablocks
so that we can see if we are fragmenting instead of reusing?


> Bug links:
> Thanks
> /Mikael

More information about the hotspot-gc-dev mailing list