< prev index next >

src/share/vm/memory/metaspace.cpp

Print this page




2965       specialized_count += msp->vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
2966       small_waste += msp->vsm()->sum_waste_in_chunks_in_use(SmallIndex);
2967       small_count += msp->vsm()->sum_count_in_chunks_in_use(SmallIndex);
2968       medium_waste += msp->vsm()->sum_waste_in_chunks_in_use(MediumIndex);
2969       medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex);
2970       humongous_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex);
2971     }
2972   }
2973   out->print_cr("Total fragmentation waste (words) doesn't count free space");
2974   out->print_cr("  data: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
2975                         SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
2976                         SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
2977                         "large count " SIZE_FORMAT,
2978              specialized_count, specialized_waste, small_count,
2979              small_waste, medium_count, medium_waste, humongous_count);
2980   if (Metaspace::using_class_space()) {
2981     print_class_waste(out);
2982   }
2983 }
2984 
































































































2985 // Dump global metaspace things from the end of ClassLoaderDataGraph
2986 void MetaspaceAux::dump(outputStream* out) {
2987   out->print_cr("All Metaspace:");
2988   out->print("data space: "); print_on(out, Metaspace::NonClassType);
2989   out->print("class space: "); print_on(out, Metaspace::ClassType);
2990   print_waste(out);
2991 }
2992 
2993 void MetaspaceAux::verify_free_chunks() {
2994   Metaspace::chunk_manager_metadata()->verify();
2995   if (Metaspace::using_class_space()) {
2996     Metaspace::chunk_manager_class()->verify();
2997   }
2998 }
2999 
3000 void MetaspaceAux::verify_capacity() {
3001 #ifdef ASSERT
3002   size_t running_sum_capacity_bytes = capacity_bytes();
3003   // For purposes of the running sum of capacity, verify against capacity
3004   size_t capacity_in_use_bytes = capacity_bytes_slow();




2965       specialized_count += msp->vsm()->sum_count_in_chunks_in_use(SpecializedIndex);
2966       small_waste += msp->vsm()->sum_waste_in_chunks_in_use(SmallIndex);
2967       small_count += msp->vsm()->sum_count_in_chunks_in_use(SmallIndex);
2968       medium_waste += msp->vsm()->sum_waste_in_chunks_in_use(MediumIndex);
2969       medium_count += msp->vsm()->sum_count_in_chunks_in_use(MediumIndex);
2970       humongous_count += msp->vsm()->sum_count_in_chunks_in_use(HumongousIndex);
2971     }
2972   }
2973   out->print_cr("Total fragmentation waste (words) doesn't count free space");
2974   out->print_cr("  data: " SIZE_FORMAT " specialized(s) " SIZE_FORMAT ", "
2975                         SIZE_FORMAT " small(s) " SIZE_FORMAT ", "
2976                         SIZE_FORMAT " medium(s) " SIZE_FORMAT ", "
2977                         "large count " SIZE_FORMAT,
2978              specialized_count, specialized_waste, small_count,
2979              small_waste, medium_count, medium_waste, humongous_count);
2980   if (Metaspace::using_class_space()) {
2981     print_class_waste(out);
2982   }
2983 }
2984 
2985 
2986 class PrintCLDMetaspaceInfoClosure : public CLDClosure {
2987 private:
2988   outputStream*  _out;
2989   size_t         _total_capacity;
2990   size_t         _total_used;
2991   size_t         _total_waste;
2992   size_t         _anonymous_count;
2993   size_t         _anonymous_total;
2994   size_t         _anonymous_waste;
2995 
2996 public:
2997   PrintCLDMetaspaceInfoClosure(outputStream* out)
2998     : _out(out), _total_capacity(0), _total_used(0),
2999       _total_waste(0), _anonymous_count(0),
3000       _anonymous_total(0), _anonymous_waste(0) { }
3001 
3002   ~PrintCLDMetaspaceInfoClosure() {
3003     size_t waste = _total_waste;
3004     _out->print_cr("");
3005     _out->print_cr("Total: capacity: " SIZE_FORMAT "KB used: " SIZE_FORMAT "KB waste: "
3006       SIZE_FORMAT "KB (%2.2f%%)",
3007     _total_capacity / K, _total_used / K, waste / K,
3008     ((float)waste * 100) / _total_capacity);
3009     _out->print_cr("Anonymous class loaders: " SIZE_FORMAT " total: " SIZE_FORMAT "KB waste: "
3010       SIZE_FORMAT "KB (%2.2f%%)",
3011       _anonymous_count, _anonymous_total / K, _anonymous_waste / K,
3012       ((float)_anonymous_waste * 100) / _anonymous_total);
3013   }
3014 
3015   void do_cld(ClassLoaderData* cld) {
3016     if (cld->is_unloading()) return;
3017     if (cld->is_anonymous()) {
3018       _anonymous_count ++;
3019       _out->print_cr("ClassLoader: for anonymous class");
3020     } else {
3021       ResourceMark rm;
3022       _out->print_cr("ClassLoader: %s", cld->loader_name());
3023     }
3024 
3025     Metaspace* msp = cld->metaspace_or_null();
3026     if (msp != NULL) {
3027       print_metaspace(msp, cld->is_anonymous());
3028     }
3029     _out->print_cr("");
3030   }
3031 
3032 private:
3033   void print_metaspace(Metaspace* msp, bool anonymous) {
3034     assert(msp != NULL, "Sanity");
3035     SpaceManager* vsm = msp->vsm();
3036 
3037   
3038     _total_capacity += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord;
3039     _total_used += vsm->sum_used_in_chunks_in_use() * BytesPerWord;
3040     _total_waste += vsm->sum_waste_in_chunks_in_use() * BytesPerWord;
3041     if (anonymous) {
3042       _total_waste += vsm->sum_free_in_chunks_in_use() * BytesPerWord;
3043       _anonymous_waste += (vsm->sum_free_in_chunks_in_use() + vsm->sum_waste_in_chunks_in_use()) * BytesPerWord;
3044       _anonymous_total += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord;
3045     }
3046 
3047     _out->print_cr("  Metadata:");
3048     _out->print_cr("     capacity: %8.2fKB used: %8.2fKB free: %8.2fKB waste: %.2fKB",
3049       ((float)vsm->sum_capacity_in_chunks_in_use() * BytesPerWord) / K,
3050       ((float)vsm->sum_used_in_chunks_in_use() * BytesPerWord) / K,
3051       ((float)vsm->sum_free_in_chunks_in_use() * BytesPerWord) / K,
3052       ((float)vsm->sum_waste_in_chunks_in_use() *BytesPerWord) / K);
3053 
3054     if (Metaspace::using_class_space()) {
3055       _out->print_cr("  Class data:");
3056       vsm = msp->class_vsm();
3057       _total_capacity += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord;
3058       _total_used += vsm->sum_used_in_chunks_in_use() * BytesPerWord;
3059       _total_waste += vsm->sum_waste_in_chunks_in_use() * BytesPerWord;
3060       if (anonymous) {
3061         _total_waste += vsm->sum_free_in_chunks_in_use() * BytesPerWord;
3062         _anonymous_waste += (vsm->sum_free_in_chunks_in_use() + vsm->sum_waste_in_chunks_in_use()) * BytesPerWord;
3063         _anonymous_total += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord;
3064       }
3065       _out->print_cr("     capacity: %8.2fKB used: %8.2fKB free: %8.2fKB waste: %.2fKB",
3066         ((float)vsm->sum_capacity_in_chunks_in_use() * BytesPerWord) / K,
3067         ((float)vsm->sum_used_in_chunks_in_use() * BytesPerWord) / K,
3068         ((float)vsm->sum_free_in_chunks_in_use() * BytesPerWord) / K,
3069         ((float)vsm->sum_waste_in_chunks_in_use() * BytesPerWord) / K);
3070     }
3071   }
3072 };
3073 
3074 
3075 void MetaspaceAux::print_cld_metadata(outputStream* out) {
3076   PrintCLDMetaspaceInfoClosure cl(out);
3077   ClassLoaderDataGraph::cld_do(&cl);
3078 }
3079 
3080 
3081 // Dump global metaspace things from the end of ClassLoaderDataGraph
3082 void MetaspaceAux::dump(outputStream* out) {
3083   out->print_cr("All Metaspace:");
3084   out->print("data space: "); print_on(out, Metaspace::NonClassType);
3085   out->print("class space: "); print_on(out, Metaspace::ClassType);
3086   print_waste(out);
3087 }
3088 
3089 void MetaspaceAux::verify_free_chunks() {
3090   Metaspace::chunk_manager_metadata()->verify();
3091   if (Metaspace::using_class_space()) {
3092     Metaspace::chunk_manager_class()->verify();
3093   }
3094 }
3095 
3096 void MetaspaceAux::verify_capacity() {
3097 #ifdef ASSERT
3098   size_t running_sum_capacity_bytes = capacity_bytes();
3099   // For purposes of the running sum of capacity, verify against capacity
3100   size_t capacity_in_use_bytes = capacity_bytes_slow();


< prev index next >