diff -r 5505fbbae3d3 -r 5fafdef522c6 src/share/vm/memory/metaspace.cpp --- a/src/share/vm/memory/metaspace.cpp Thu Nov 29 13:55:49 2012 -0800 +++ b/src/share/vm/memory/metaspace.cpp Fri Nov 30 12:01:34 2012 -0800 @@ -109,7 +109,6 @@ size_t Metablock::_overhead = 0; #endif - // Pointer to list of Metachunks. class ChunkList VALUE_OBJ_CLASS_SPEC { // List of free chunks @@ -326,10 +325,12 @@ bool expand_by(size_t words, bool pre_touch = false); bool shrink_by(size_t words); +#ifdef ASSERT // Debug support static void verify_virtual_space_total(); static void verify_virtual_space_count(); void mangle(); +#endif void print_on(outputStream* st) const; }; @@ -622,8 +623,8 @@ void locked_print_chunks_in_use_on(outputStream* st) const; void verify(); + NOT_PRODUCT(void mangle_freed_chunks();) #ifdef ASSERT - void mangle_freed_chunks(); void verify_allocation_total(); #endif }; @@ -712,7 +713,7 @@ bottom(), top(), end(), word_size()); } -#ifdef ASSERT +#ifndef PRODUCT void Metachunk::mangle() { // Mangle the payload of the chunk and not the links that // maintain list of chunks. @@ -720,7 +721,7 @@ size_t word_size = capacity_word_size() - overhead(); Copy::fill_to_words(start, word_size, metadata_chunk_initialize); } -#endif // ASSERT +#endif // PRODUCT void Metachunk::verify() { #ifdef ASSERT @@ -918,10 +919,12 @@ vs->high_boundary()); } +#ifdef ASSERT void VirtualSpaceNode::mangle() { size_t word_size = capacity_words_in_vs(); Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1); } +#endif // ASSERT // VirtualSpaceList methods // Space allocated from the VirtualSpace @@ -1986,16 +1989,14 @@ locked_print_chunks_in_use_on(gclog_or_tty); } + // 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(), sum_count_in_chunks_in_use()); -#ifdef ASSERT - // Mangle freed memory. - mangle_freed_chunks(); -#endif // ASSERT - // Add all the chunks in use by this space manager // to the global list of free chunks. @@ -2274,7 +2275,7 @@ " waste " SIZE_FORMAT, curr_total, used, free, capacity, waste); } -#ifdef ASSERT +#ifndef PRODUCT void SpaceManager::mangle_freed_chunks() { for (ChunkIndex index = SmallIndex; index < NumberOfInUseLists; @@ -2292,11 +2293,16 @@ } } } -#endif // ASSERT +#endif // PRODUCT // MetaspaceAux +size_t MetaspaceAux::used_in_bytes() { + return (Metaspace::class_space_list()->used_words_sum() + + Metaspace::space_list()->used_words_sum()) * BytesPerWord; +} + size_t MetaspaceAux::used_in_bytes(Metaspace::MetadataType mdtype) { size_t used = 0; ClassLoaderDataGraphMetaspaceIterator iter; @@ -2325,6 +2331,11 @@ // The total words available for metadata allocation. This // uses Metaspace capacity_words() which is the total words // in chunks allocated for a Metaspace. +size_t MetaspaceAux::capacity_in_bytes() { + return (Metaspace::class_space_list()->capacity_words_sum() + + Metaspace::space_list()->capacity_words_sum()) * BytesPerWord; +} + size_t MetaspaceAux::capacity_in_bytes(Metaspace::MetadataType mdtype) { size_t capacity = free_chunks_total(mdtype); ClassLoaderDataGraphMetaspaceIterator iter; @@ -2337,6 +2348,11 @@ return capacity * BytesPerWord; } +size_t MetaspaceAux::reserved_in_bytes() { + return (Metaspace::class_space_list()->virtual_space_total() + + Metaspace::space_list()->virtual_space_total()) * BytesPerWord; +} + size_t MetaspaceAux::reserved_in_bytes(Metaspace::MetadataType mdtype) { size_t reserved = (mdtype == Metaspace::ClassType) ? Metaspace::class_space_list()->virtual_space_total() :