When retiring chunks, the leftover space in the old chunk is added to the free block list via SpaceManager::deallocate(). Here, we still unnecessarily assume a lower size limit of TreeChunk<Metablock, FreeList<Metablock> >::min_size(), which is unnecessary high and causes leaks which show up as waste in the retired chunks.
By correctly using SmallBlocks::small_block_min_size() when deallocating the leftover chunk space on chunk retirement, we can reduce that kind of waste to almost nil.
Fix is easy:
--- a/src/hotspot/share/memory/metaspace.cpp Mon Apr 30 15:10:34 2018 +0200
+++ b/src/hotspot/share/memory/metaspace.cpp Mon Apr 30 15:40:15 2018 +0200
@@ -3493,7 +3494,7 @@
void SpaceManager::retire_current_chunk() {
if (current_chunk() != NULL) {
size_t remaining_words = current_chunk()->free_word_size();
- if (remaining_words >= BlockFreelist::min_dictionary_size()) {
+ if (remaining_words >= SmallBlocks::small_block_min_size()) {
MetaWord* ptr = current_chunk()->allocate(remaining_words);
deallocate(ptr, remaining_words);
account_for_allocation(remaining_words);
- relates to
-
JDK-8164921 Memory leaked when instrumentation.retransformClasses() is called repeatedly
-
- Resolved
-