We waste memory because:
- we abandon chunk remainders when creating a new chunk
- we often abandon old storage when we reallocate an array within the arena
I attempted to measure how much memory is wasted and got, for C2, to about 5-10%. Would be nice to reduce fragmentation.
One way to go about it would be to reuse the memory via freelist or some blocktree. Metaspace does that. The problem is that, unlike Metaspace, these arenas get rolled back (HandleArea, ResourceArea) and an efficient way must be found to cut those blocks that are part of the rolled-back portion from the freelist, and to do that very quickly since we use ResourceMarks often.
- we abandon chunk remainders when creating a new chunk
- we often abandon old storage when we reallocate an array within the arena
I attempted to measure how much memory is wasted and got, for C2, to about 5-10%. Would be nice to reduce fragmentation.
One way to go about it would be to reuse the memory via freelist or some blocktree. Metaspace does that. The problem is that, unlike Metaspace, these arenas get rolled back (HandleArea, ResourceArea) and an efficient way must be found to cut those blocks that are part of the rolled-back portion from the freelist, and to do that very quickly since we use ResourceMarks often.