Segmented code cache is a new feature introduced in Java 9 that divides the code cache into segments, this improves performance to a considerable extent. But there can be some memory wastage due to fixed size per code heap, in case of small code cache, one code heap is full and there is still space in another code heap.
So what are possible workarounds to overcome these memory issues?
The Risks and Assumptions of the Segmented Code Cache JEP states the same in a cleaner way:-
Having a fixed size per code heap leads to a potential waste of memory in case one code heap is full and there is still space in another code heap. Especially for very small code cache sizes, it may happen that the compilers are shut off even if there is still space available. To solve this problem an option will be added to turn off the segmentation for small code-cache sizes.