When a Metaspace allocation request cannot be satisfied by the current chunk the chunk is retired and a new chunk is requested. This causes whatever is left in the chunk to be effectively leaked. It might be a good idea to add the last piece of each chunk to the SpaceManager's block dictionary. The reason I'm seeing this is that when running the test attached to JDK-8004241 the waste in the class space is 20% when running with MaxMetaspaceSize=256m. We end up with something like: Metaspace total 171164K, used 146740K, reserved 178176K data space 68764K, used 66765K, reserved 75776K class space 102400K, used 79975K, reserved 102400K while trying to allocate ~40 words in the class space.
|