In ZGC there are three different types of pages in which objects can be allocated:
- Small pages are used for regular objects (< 256k)
- Medium pages are used for medium sized objects (limit depends on heap size)
- Large pages are used for objects above the medium limit
Currently small pages are allocated at low addresses and medium/large pages are allocated at high addresses. When a page is no longer used it is returned to the ZPageCache to be reused.
The page cache has a feature to split a page into the requested size if no exact match is found. This make the page allocation for larger pages more efficient, but can lead to a lot of fragmentation. It is pretty easy to create a test that fragment the address space by splitting out "small" large pages from very big ones. By doing this over and over again and also increasing the sizes slightly, we end up running out of virtual address space.
The main problem is the splitting of large pages into smaller large pages since these will not be moved around by the GC, they are only freed once the object is no longer reachable.
This enhancement aim to remove the caching of large objects (and with that the possibility to split of pages from them) and instead cache the underlying physical memory to allow for efficient reuse of memory.
The plan is to still allow caching of small and medium pages and the ability to split pages from those when possible.
- Small pages are used for regular objects (< 256k)
- Medium pages are used for medium sized objects (limit depends on heap size)
- Large pages are used for objects above the medium limit
Currently small pages are allocated at low addresses and medium/large pages are allocated at high addresses. When a page is no longer used it is returned to the ZPageCache to be reused.
The page cache has a feature to split a page into the requested size if no exact match is found. This make the page allocation for larger pages more efficient, but can lead to a lot of fragmentation. It is pretty easy to create a test that fragment the address space by splitting out "small" large pages from very big ones. By doing this over and over again and also increasing the sizes slightly, we end up running out of virtual address space.
The main problem is the splitting of large pages into smaller large pages since these will not be moved around by the GC, they are only freed once the object is no longer reachable.
This enhancement aim to remove the caching of large objects (and with that the possibility to split of pages from them) and instead cache the underlying physical memory to allow for efficient reuse of memory.
The plan is to still allow caching of small and medium pages and the ability to split pages from those when possible.