src/share/vm/memory/metaspace.cpp

Print this page
rev 4168 : 8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
Summary: Call purge() on CLDG after sweep(), reorder purge() call in GenCollectedHeap and enable some additional logging
Reviewed-by:

@@ -1307,12 +1307,11 @@
     if (PrintGCDetails && Verbose) {
       size_t new_capacity_until_GC = MetaspaceGC::capacity_until_GC_in_bytes();
       gclog_or_tty->print_cr("  metaspace HWM: %.1fK", new_capacity_until_GC / (double) K);
     }
   }
-  assert(vsl->used_bytes_sum() == used_after_gc &&
-         used_after_gc <= vsl->capacity_bytes_sum(),
+  assert(used_after_gc <= vsl->capacity_bytes_sum(),
          "sanity check");
 
 }
 
 // Metadebug methods

@@ -1968,10 +1967,11 @@
     gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this);
   }
 }
 
 SpaceManager::~SpaceManager() {
+  const size_t in_use_before = sum_capacity_in_chunks_in_use();
   MutexLockerEx fcl(SpaceManager::expand_lock(),
                     Mutex::_no_safepoint_check_flag);
 
   ChunkManager* chunk_manager = vs_list()->chunk_manager();
 

@@ -1985,11 +1985,11 @@
   // Mangle freed memory.
   NOT_PRODUCT(mangle_freed_chunks();)
 
   // Have to update before the chunks_in_use lists are emptied
   // below.
-  chunk_manager->inc_free_chunks_total(sum_capacity_in_chunks_in_use(),
+  chunk_manager->inc_free_chunks_total(in_use_before,
                                        sum_count_in_chunks_in_use());
 
   // Add all the chunks in use by this space manager
   // to the global list of free chunks.