< prev index next >

src/hotspot/share/memory/metaspace.cpp

Print this page

        

@@ -1214,10 +1214,12 @@
 
   static void init_allocation_fail_alot_count();
 #ifdef ASSERT
   static bool test_metadata_failure();
 #endif
+
+  static void test_anon_delegating_metaspace_sizing(ClassLoaderMetaspace* msp) PRODUCT_RETURN;
 };
 
 int Metadebug::_allocation_fail_alot_count = 0;
 
 //  SpaceManager - used by Metaspace to handle allocations

@@ -1313,10 +1315,11 @@
 
   static size_t smallest_chunk_size(bool is_class)    { return specialized_chunk_size(is_class); }
 
   // Accessors
   bool is_class() const { return _mdtype == Metaspace::ClassType; }
+  Metaspace::MetaspaceType metaspace_type() const { return _space_type; }
 
   size_t specialized_chunk_size() const { return specialized_chunk_size(is_class()); }
   size_t small_chunk_size()       const { return small_chunk_size(is_class()); }
   size_t medium_chunk_size()      const { return medium_chunk_size(is_class()); }
 

@@ -5275,10 +5278,33 @@
     ChunkIndex index = manager.list_index(ClassMediumChunk + 1);
     assert(index == HumongousIndex, "Wrong index returned. Got index: %d", (int)index);
   }
 }
 
+void Metadebug::test_anon_delegating_metaspace_sizing(ClassLoaderMetaspace* msp) {
+  SpaceManager* smgr = msp->vsm();
+  assert(smgr != NULL, "Sanity");
+
+  // Anonymous and refection delegating classloader should use up to 
+  // _anon_and_delegating_metadata_specialize_chunk_limit small chunks before jump to midium chunks,
+  // to reduce memory waste.
+  const size_t small_chunk_size_limit = SpaceManager::_anon_and_delegating_metadata_specialize_chunk_limit *
+     SpaceManager::small_chunk_size(false);
+ 
+  if (smgr->metaspace_type() == Metaspace::AnonymousMetaspaceType ||
+      smgr->metaspace_type() == Metaspace::ReflectionMetaspaceType) {
+    if (smgr->sum_used_in_chunks_in_use() <= small_chunk_size_limit) {
+      assert(smgr->sum_capacity_in_chunks_in_use() <= small_chunk_size_limit,
+        "Incorrect sizing for Anonymous or Reflection data metadata space");
+    }
+  }
+}
+
+void Metaspace_test_anonymous_delegating_classloader_sizing(ClassLoaderMetaspace* msp) {
+  Metadebug::test_anon_delegating_metaspace_sizing(msp);
+}
+
 #endif // !PRODUCT
 
 #ifdef ASSERT
 
 // The following test is placed here instead of a gtest / unittest file
< prev index next >