Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8202424

Metaspace: on chunk retirement, use correct lower limit on chunksize when adding blocks to free blocks list.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 11
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b13

      Description

      JDK-8164921 got rid of dark matter by lowering the smallest block size which can be managed by the free block list to sizeof(MetaBlock).

      When retiring chunks, the leftover space in the old chunk is added to the free block list via SpaceManager::deallocate(). Here, we still unnecessarily assume a lower size limit of TreeChunk<Metablock, FreeList<Metablock> >::min_size(), which is unnecessary high and causes leaks which show up as waste in the retired chunks.

      By correctly using SmallBlocks::small_block_min_size() when deallocating the leftover chunk space on chunk retirement, we can reduce that kind of waste to almost nil.

      Fix is easy:

      --- a/src/hotspot/share/memory/metaspace.cpp Mon Apr 30 15:10:34 2018 +0200
      +++ b/src/hotspot/share/memory/metaspace.cpp Mon Apr 30 15:40:15 2018 +0200
      @@ -3493,7 +3494,7 @@
       void SpaceManager::retire_current_chunk() {
         if (current_chunk() != NULL) {
           size_t remaining_words = current_chunk()->free_word_size();
      - if (remaining_words >= BlockFreelist::min_dictionary_size()) {
      + if (remaining_words >= SmallBlocks::small_block_min_size()) {
             MetaWord* ptr = current_chunk()->allocate(remaining_words);
             deallocate(ptr, remaining_words);
             account_for_allocation(remaining_words);

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stuefe Thomas Stuefe
                Reporter:
                stuefe Thomas Stuefe
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: