< prev index next >

src/share/vm/memory/metaspace.cpp

Print this page

        

*** 2980,2989 **** --- 2980,3085 ---- if (Metaspace::using_class_space()) { print_class_waste(out); } } + + class PrintCLDMetaspaceInfoClosure : public CLDClosure { + private: + outputStream* _out; + size_t _total_capacity; + size_t _total_used; + size_t _total_waste; + size_t _anonymous_count; + size_t _anonymous_total; + size_t _anonymous_waste; + + public: + PrintCLDMetaspaceInfoClosure(outputStream* out) + : _out(out), _total_capacity(0), _total_used(0), + _total_waste(0), _anonymous_count(0), + _anonymous_total(0), _anonymous_waste(0) { } + + ~PrintCLDMetaspaceInfoClosure() { + size_t waste = _total_waste; + _out->print_cr(""); + _out->print_cr("Total: capacity: " SIZE_FORMAT "KB used: " SIZE_FORMAT "KB waste: " + SIZE_FORMAT "KB (%2.2f%%)", + _total_capacity / K, _total_used / K, waste / K, + ((float)waste * 100) / _total_capacity); + _out->print_cr("Anonymous class loaders: " SIZE_FORMAT " total: " SIZE_FORMAT "KB waste: " + SIZE_FORMAT "KB (%2.2f%%)", + _anonymous_count, _anonymous_total / K, _anonymous_waste / K, + ((float)_anonymous_waste * 100) / _anonymous_total); + } + + void do_cld(ClassLoaderData* cld) { + if (cld->is_unloading()) return; + if (cld->is_anonymous()) { + _anonymous_count ++; + _out->print_cr("ClassLoader: for anonymous class"); + } else { + ResourceMark rm; + _out->print_cr("ClassLoader: %s", cld->loader_name()); + } + + Metaspace* msp = cld->metaspace_or_null(); + if (msp != NULL) { + print_metaspace(msp, cld->is_anonymous()); + } + _out->print_cr(""); + } + + private: + void print_metaspace(Metaspace* msp, bool anonymous) { + assert(msp != NULL, "Sanity"); + SpaceManager* vsm = msp->vsm(); + + + _total_capacity += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord; + _total_used += vsm->sum_used_in_chunks_in_use() * BytesPerWord; + _total_waste += vsm->sum_waste_in_chunks_in_use() * BytesPerWord; + if (anonymous) { + _total_waste += vsm->sum_free_in_chunks_in_use() * BytesPerWord; + _anonymous_waste += (vsm->sum_free_in_chunks_in_use() + vsm->sum_waste_in_chunks_in_use()) * BytesPerWord; + _anonymous_total += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord; + } + + _out->print_cr(" Metadata:"); + _out->print_cr(" capacity: %8.2fKB used: %8.2fKB free: %8.2fKB waste: %.2fKB", + ((float)vsm->sum_capacity_in_chunks_in_use() * BytesPerWord) / K, + ((float)vsm->sum_used_in_chunks_in_use() * BytesPerWord) / K, + ((float)vsm->sum_free_in_chunks_in_use() * BytesPerWord) / K, + ((float)vsm->sum_waste_in_chunks_in_use() *BytesPerWord) / K); + + if (Metaspace::using_class_space()) { + _out->print_cr(" Class data:"); + vsm = msp->class_vsm(); + _total_capacity += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord; + _total_used += vsm->sum_used_in_chunks_in_use() * BytesPerWord; + _total_waste += vsm->sum_waste_in_chunks_in_use() * BytesPerWord; + if (anonymous) { + _total_waste += vsm->sum_free_in_chunks_in_use() * BytesPerWord; + _anonymous_waste += (vsm->sum_free_in_chunks_in_use() + vsm->sum_waste_in_chunks_in_use()) * BytesPerWord; + _anonymous_total += vsm->sum_capacity_in_chunks_in_use() * BytesPerWord; + } + _out->print_cr(" capacity: %8.2fKB used: %8.2fKB free: %8.2fKB waste: %.2fKB", + ((float)vsm->sum_capacity_in_chunks_in_use() * BytesPerWord) / K, + ((float)vsm->sum_used_in_chunks_in_use() * BytesPerWord) / K, + ((float)vsm->sum_free_in_chunks_in_use() * BytesPerWord) / K, + ((float)vsm->sum_waste_in_chunks_in_use() * BytesPerWord) / K); + } + } + }; + + + void MetaspaceAux::print_cld_metadata(outputStream* out) { + PrintCLDMetaspaceInfoClosure cl(out); + ClassLoaderDataGraph::cld_do(&cl); + } + + // Dump global metaspace things from the end of ClassLoaderDataGraph void MetaspaceAux::dump(outputStream* out) { out->print_cr("All Metaspace:"); out->print("data space: "); print_on(out, Metaspace::NonClassType); out->print("class space: "); print_on(out, Metaspace::ClassType);
< prev index next >