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

VectorSet::clear can cause fragmentation

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b27

      Backports

        Description

        VectorSet::clear purportedly frees allocated storages for the backing array if the array is large enough (100 32-bit words). Since the array is allocated in a resource arena, then unless the VectorSet::_data array is at the current end of the arena then freeing will be a no-op and the "freed" memory will remain allocated in an unusable state until the arena usage is reclaimed at the next ResourceMark. Any subsequent growth of the backing array will claim new storage at the end of the arena.

        To avoid this kind of fragmentation it might be better to keep the backing array around, maintaining both current _size along with a _max (the actually allocated size) so that we don't excessively clear memory we're not using.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                redestad Claes Redestad
                Reporter:
                redestad Claes Redestad
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: