< prev index next >
src/hotspot/share/memory/metaspace.cpp
Print this page
rev 49170 : imported patch meta-coal-0301
rev 49171 : imported patch 8185034-metaspace-cleanup-1-rename-metaspaceaux
*** 1819,1832 ****
assert_lock_strong(SpaceManager::expand_lock());
_reserved_words = _reserved_words - v;
}
#define assert_committed_below_limit() \
! assert(MetaspaceAux::committed_bytes() <= MaxMetaspaceSize, \
"Too much committed memory. Committed: " SIZE_FORMAT \
" limit (MaxMetaspaceSize): " SIZE_FORMAT, \
! MetaspaceAux::committed_bytes(), MaxMetaspaceSize);
void VirtualSpaceList::inc_committed_words(size_t v) {
assert_lock_strong(SpaceManager::expand_lock());
_committed_words = _committed_words + v;
--- 1819,1832 ----
assert_lock_strong(SpaceManager::expand_lock());
_reserved_words = _reserved_words - v;
}
#define assert_committed_below_limit() \
! assert(MetaspaceUtils::committed_bytes() <= MaxMetaspaceSize, \
"Too much committed memory. Committed: " SIZE_FORMAT \
" limit (MaxMetaspaceSize): " SIZE_FORMAT, \
! MetaspaceUtils::committed_bytes(), MaxMetaspaceSize);
void VirtualSpaceList::inc_committed_words(size_t v) {
assert_lock_strong(SpaceManager::expand_lock());
_committed_words = _committed_words + v;
*** 2417,2453 ****
_capacity_until_GC = MaxMetaspaceSize;
}
void MetaspaceGC::post_initialize() {
// Reset the high-water mark once the VM initialization is done.
! _capacity_until_GC = MAX2(MetaspaceAux::committed_bytes(), MetaspaceSize);
}
bool MetaspaceGC::can_expand(size_t word_size, bool is_class) {
// Check if the compressed class space is full.
if (is_class && Metaspace::using_class_space()) {
! size_t class_committed = MetaspaceAux::committed_bytes(Metaspace::ClassType);
if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) {
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (CompressedClassSpaceSize = " SIZE_FORMAT " words)",
(is_class ? "class" : "non-class"), word_size, CompressedClassSpaceSize / sizeof(MetaWord));
return false;
}
}
// Check if the user has imposed a limit on the metaspace memory.
! size_t committed_bytes = MetaspaceAux::committed_bytes();
if (committed_bytes + word_size * BytesPerWord > MaxMetaspaceSize) {
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (MaxMetaspaceSize = " SIZE_FORMAT " words)",
(is_class ? "class" : "non-class"), word_size, MaxMetaspaceSize / sizeof(MetaWord));
return false;
}
return true;
}
size_t MetaspaceGC::allowed_expansion() {
! size_t committed_bytes = MetaspaceAux::committed_bytes();
size_t capacity_until_gc = capacity_until_GC();
assert(capacity_until_gc >= committed_bytes,
"capacity_until_gc: " SIZE_FORMAT " < committed_bytes: " SIZE_FORMAT,
capacity_until_gc, committed_bytes);
--- 2417,2453 ----
_capacity_until_GC = MaxMetaspaceSize;
}
void MetaspaceGC::post_initialize() {
// Reset the high-water mark once the VM initialization is done.
! _capacity_until_GC = MAX2(MetaspaceUtils::committed_bytes(), MetaspaceSize);
}
bool MetaspaceGC::can_expand(size_t word_size, bool is_class) {
// Check if the compressed class space is full.
if (is_class && Metaspace::using_class_space()) {
! size_t class_committed = MetaspaceUtils::committed_bytes(Metaspace::ClassType);
if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) {
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (CompressedClassSpaceSize = " SIZE_FORMAT " words)",
(is_class ? "class" : "non-class"), word_size, CompressedClassSpaceSize / sizeof(MetaWord));
return false;
}
}
// Check if the user has imposed a limit on the metaspace memory.
! size_t committed_bytes = MetaspaceUtils::committed_bytes();
if (committed_bytes + word_size * BytesPerWord > MaxMetaspaceSize) {
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (MaxMetaspaceSize = " SIZE_FORMAT " words)",
(is_class ? "class" : "non-class"), word_size, MaxMetaspaceSize / sizeof(MetaWord));
return false;
}
return true;
}
size_t MetaspaceGC::allowed_expansion() {
! size_t committed_bytes = MetaspaceUtils::committed_bytes();
size_t capacity_until_gc = capacity_until_GC();
assert(capacity_until_gc >= committed_bytes,
"capacity_until_gc: " SIZE_FORMAT " < committed_bytes: " SIZE_FORMAT,
capacity_until_gc, committed_bytes);
*** 2473,2483 ****
// However, if the chunk free lists becomes fragmented, then the memory may
// not be available for future allocations and the memory is therefore "in use".
// Including the chunk free lists in the definition of "in use" is therefore
// necessary. Not including the chunk free lists can cause capacity_until_GC to
// shrink below committed_bytes() and this has caused serious bugs in the past.
! const size_t used_after_gc = MetaspaceAux::committed_bytes();
const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
const double maximum_used_percentage = 1.0 - minimum_free_percentage;
--- 2473,2483 ----
// However, if the chunk free lists becomes fragmented, then the memory may
// not be available for future allocations and the memory is therefore "in use".
// Including the chunk free lists in the definition of "in use" is therefore
// necessary. Not including the chunk free lists can cause capacity_until_GC to
// shrink below committed_bytes() and this has caused serious bugs in the past.
! const size_t used_after_gc = MetaspaceUtils::committed_bytes();
const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
const double maximum_used_percentage = 1.0 - minimum_free_percentage;
*** 3482,3512 ****
// Total of allocated Metachunks and allocated Metachunks count
// for each SpaceManager
_allocated_chunks_words = _allocated_chunks_words + words;
_allocated_chunks_count++;
// Global total of capacity in allocated Metachunks
! MetaspaceAux::inc_capacity(mdtype(), words);
// Global total of allocated Metablocks.
// used_words_slow() includes the overhead in each
// Metachunk so include it in the used when the
// Metachunk is first added (so only added once per
// Metachunk).
! MetaspaceAux::inc_used(mdtype(), Metachunk::overhead());
}
void SpaceManager::inc_used_metrics(size_t words) {
// Add to the per SpaceManager total
Atomic::add(words, &_allocated_blocks_words);
// Add to the global total
! MetaspaceAux::inc_used(mdtype(), words);
}
void SpaceManager::dec_total_from_size_metrics() {
! MetaspaceAux::dec_capacity(mdtype(), allocated_chunks_words());
! MetaspaceAux::dec_used(mdtype(), allocated_blocks_words());
// Also deduct the overhead per Metachunk
! MetaspaceAux::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead());
}
void SpaceManager::initialize() {
Metadebug::init_allocation_fail_alot_count();
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
--- 3482,3512 ----
// Total of allocated Metachunks and allocated Metachunks count
// for each SpaceManager
_allocated_chunks_words = _allocated_chunks_words + words;
_allocated_chunks_count++;
// Global total of capacity in allocated Metachunks
! MetaspaceUtils::inc_capacity(mdtype(), words);
// Global total of allocated Metablocks.
// used_words_slow() includes the overhead in each
// Metachunk so include it in the used when the
// Metachunk is first added (so only added once per
// Metachunk).
! MetaspaceUtils::inc_used(mdtype(), Metachunk::overhead());
}
void SpaceManager::inc_used_metrics(size_t words) {
// Add to the per SpaceManager total
Atomic::add(words, &_allocated_blocks_words);
// Add to the global total
! MetaspaceUtils::inc_used(mdtype(), words);
}
void SpaceManager::dec_total_from_size_metrics() {
! MetaspaceUtils::dec_capacity(mdtype(), allocated_chunks_words());
! MetaspaceUtils::dec_used(mdtype(), allocated_blocks_words());
// Also deduct the overhead per Metachunk
! MetaspaceUtils::dec_used(mdtype(), allocated_chunks_count() * Metachunk::overhead());
}
void SpaceManager::initialize() {
Metadebug::init_allocation_fail_alot_count();
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
*** 3775,3815 ****
out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT
" free " SIZE_FORMAT " capacity " SIZE_FORMAT
" waste " SIZE_FORMAT, curr_total, used, free, capacity, waste);
}
! // MetaspaceAux
! size_t MetaspaceAux::_capacity_words[] = {0, 0};
! volatile size_t MetaspaceAux::_used_words[] = {0, 0};
! size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) {
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
return list == NULL ? 0 : list->free_bytes();
}
! size_t MetaspaceAux::free_bytes() {
return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType);
}
! void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
assert_lock_strong(SpaceManager::expand_lock());
assert(words <= capacity_words(mdtype),
"About to decrement below 0: words " SIZE_FORMAT
" is greater than _capacity_words[%u] " SIZE_FORMAT,
words, mdtype, capacity_words(mdtype));
_capacity_words[mdtype] -= words;
}
! void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
assert_lock_strong(SpaceManager::expand_lock());
// Needs to be atomic
_capacity_words[mdtype] += words;
}
! void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) {
assert(words <= used_words(mdtype),
"About to decrement below 0: words " SIZE_FORMAT
" is greater than _used_words[%u] " SIZE_FORMAT,
words, mdtype, used_words(mdtype));
// For CMS deallocation of the Metaspaces occurs during the
--- 3775,3815 ----
out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT
" free " SIZE_FORMAT " capacity " SIZE_FORMAT
" waste " SIZE_FORMAT, curr_total, used, free, capacity, waste);
}
! // MetaspaceUtils
! size_t MetaspaceUtils::_capacity_words[] = {0, 0};
! volatile size_t MetaspaceUtils::_used_words[] = {0, 0};
! size_t MetaspaceUtils::free_bytes(Metaspace::MetadataType mdtype) {
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
return list == NULL ? 0 : list->free_bytes();
}
! size_t MetaspaceUtils::free_bytes() {
return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType);
}
! void MetaspaceUtils::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
assert_lock_strong(SpaceManager::expand_lock());
assert(words <= capacity_words(mdtype),
"About to decrement below 0: words " SIZE_FORMAT
" is greater than _capacity_words[%u] " SIZE_FORMAT,
words, mdtype, capacity_words(mdtype));
_capacity_words[mdtype] -= words;
}
! void MetaspaceUtils::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
assert_lock_strong(SpaceManager::expand_lock());
// Needs to be atomic
_capacity_words[mdtype] += words;
}
! void MetaspaceUtils::dec_used(Metaspace::MetadataType mdtype, size_t words) {
assert(words <= used_words(mdtype),
"About to decrement below 0: words " SIZE_FORMAT
" is greater than _used_words[%u] " SIZE_FORMAT,
words, mdtype, used_words(mdtype));
// For CMS deallocation of the Metaspaces occurs during the
*** 3817,3835 ****
// is not enough since allocation is on a per Metaspace basis
// and protected by the Metaspace lock.
Atomic::sub(words, &_used_words[mdtype]);
}
! void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) {
// _used_words tracks allocations for
// each piece of metadata. Those allocations are
// generally done concurrently by different application
// threads so must be done atomically.
Atomic::add(words, &_used_words[mdtype]);
}
! size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) {
size_t used = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
Metaspace* msp = iter.get_next();
// Sum allocated_blocks_words for each metaspace
--- 3817,3835 ----
// is not enough since allocation is on a per Metaspace basis
// and protected by the Metaspace lock.
Atomic::sub(words, &_used_words[mdtype]);
}
! void MetaspaceUtils::inc_used(Metaspace::MetadataType mdtype, size_t words) {
// _used_words tracks allocations for
// each piece of metadata. Those allocations are
// generally done concurrently by different application
// threads so must be done atomically.
Atomic::add(words, &_used_words[mdtype]);
}
! size_t MetaspaceUtils::used_bytes_slow(Metaspace::MetadataType mdtype) {
size_t used = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
Metaspace* msp = iter.get_next();
// Sum allocated_blocks_words for each metaspace
*** 3838,3848 ****
}
}
return used * BytesPerWord;
}
! size_t MetaspaceAux::free_bytes_slow(Metaspace::MetadataType mdtype) {
size_t free = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
Metaspace* msp = iter.get_next();
if (msp != NULL) {
--- 3838,3848 ----
}
}
return used * BytesPerWord;
}
! size_t MetaspaceUtils::free_bytes_slow(Metaspace::MetadataType mdtype) {
size_t free = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
Metaspace* msp = iter.get_next();
if (msp != NULL) {
*** 3850,3860 ****
}
}
return free * BytesPerWord;
}
! size_t MetaspaceAux::capacity_bytes_slow(Metaspace::MetadataType mdtype) {
if ((mdtype == Metaspace::ClassType) && !Metaspace::using_class_space()) {
return 0;
}
// Don't count the space in the freelists. That space will be
// added to the capacity calculation as needed.
--- 3850,3860 ----
}
}
return free * BytesPerWord;
}
! size_t MetaspaceUtils::capacity_bytes_slow(Metaspace::MetadataType mdtype) {
if ((mdtype == Metaspace::ClassType) && !Metaspace::using_class_space()) {
return 0;
}
// Don't count the space in the freelists. That space will be
// added to the capacity calculation as needed.
*** 3867,3877 ****
}
}
return capacity * BytesPerWord;
}
! size_t MetaspaceAux::capacity_bytes_slow() {
#ifdef PRODUCT
// Use capacity_bytes() in PRODUCT instead of this function.
guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT");
#endif
size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType);
--- 3867,3877 ----
}
}
return capacity * BytesPerWord;
}
! size_t MetaspaceUtils::capacity_bytes_slow() {
#ifdef PRODUCT
// Use capacity_bytes() in PRODUCT instead of this function.
guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT");
#endif
size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType);
*** 3884,3946 ****
class_capacity, non_class_capacity);
return class_capacity + non_class_capacity;
}
! size_t MetaspaceAux::reserved_bytes(Metaspace::MetadataType mdtype) {
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
return list == NULL ? 0 : list->reserved_bytes();
}
! size_t MetaspaceAux::committed_bytes(Metaspace::MetadataType mdtype) {
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
return list == NULL ? 0 : list->committed_bytes();
}
! size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); }
! size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) {
ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype);
if (chunk_manager == NULL) {
return 0;
}
chunk_manager->slow_verify();
return chunk_manager->free_chunks_total_words();
}
! size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) {
return free_chunks_total_words(mdtype) * BytesPerWord;
}
! size_t MetaspaceAux::free_chunks_total_words() {
return free_chunks_total_words(Metaspace::ClassType) +
free_chunks_total_words(Metaspace::NonClassType);
}
! size_t MetaspaceAux::free_chunks_total_bytes() {
return free_chunks_total_words() * BytesPerWord;
}
! bool MetaspaceAux::has_chunk_free_list(Metaspace::MetadataType mdtype) {
return Metaspace::get_chunk_manager(mdtype) != NULL;
}
! MetaspaceChunkFreeListSummary MetaspaceAux::chunk_free_list_summary(Metaspace::MetadataType mdtype) {
if (!has_chunk_free_list(mdtype)) {
return MetaspaceChunkFreeListSummary();
}
const ChunkManager* cm = Metaspace::get_chunk_manager(mdtype);
return cm->chunk_free_list_summary();
}
! void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) {
log_info(gc, metaspace)("Metaspace: " SIZE_FORMAT "K->" SIZE_FORMAT "K(" SIZE_FORMAT "K)",
prev_metadata_used/K, used_bytes()/K, reserved_bytes()/K);
}
! void MetaspaceAux::print_on(outputStream* out) {
Metaspace::MetadataType nct = Metaspace::NonClassType;
out->print_cr(" Metaspace "
"used " SIZE_FORMAT "K, "
"capacity " SIZE_FORMAT "K, "
--- 3884,3946 ----
class_capacity, non_class_capacity);
return class_capacity + non_class_capacity;
}
! size_t MetaspaceUtils::reserved_bytes(Metaspace::MetadataType mdtype) {
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
return list == NULL ? 0 : list->reserved_bytes();
}
! size_t MetaspaceUtils::committed_bytes(Metaspace::MetadataType mdtype) {
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
return list == NULL ? 0 : list->committed_bytes();
}
! size_t MetaspaceUtils::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); }
! size_t MetaspaceUtils::free_chunks_total_words(Metaspace::MetadataType mdtype) {
ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype);
if (chunk_manager == NULL) {
return 0;
}
chunk_manager->slow_verify();
return chunk_manager->free_chunks_total_words();
}
! size_t MetaspaceUtils::free_chunks_total_bytes(Metaspace::MetadataType mdtype) {
return free_chunks_total_words(mdtype) * BytesPerWord;
}
! size_t MetaspaceUtils::free_chunks_total_words() {
return free_chunks_total_words(Metaspace::ClassType) +
free_chunks_total_words(Metaspace::NonClassType);
}
! size_t MetaspaceUtils::free_chunks_total_bytes() {
return free_chunks_total_words() * BytesPerWord;
}
! bool MetaspaceUtils::has_chunk_free_list(Metaspace::MetadataType mdtype) {
return Metaspace::get_chunk_manager(mdtype) != NULL;
}
! MetaspaceChunkFreeListSummary MetaspaceUtils::chunk_free_list_summary(Metaspace::MetadataType mdtype) {
if (!has_chunk_free_list(mdtype)) {
return MetaspaceChunkFreeListSummary();
}
const ChunkManager* cm = Metaspace::get_chunk_manager(mdtype);
return cm->chunk_free_list_summary();
}
! void MetaspaceUtils::print_metaspace_change(size_t prev_metadata_used) {
log_info(gc, metaspace)("Metaspace: " SIZE_FORMAT "K->" SIZE_FORMAT "K(" SIZE_FORMAT "K)",
prev_metadata_used/K, used_bytes()/K, reserved_bytes()/K);
}
! void MetaspaceUtils::print_on(outputStream* out) {
Metaspace::MetadataType nct = Metaspace::NonClassType;
out->print_cr(" Metaspace "
"used " SIZE_FORMAT "K, "
"capacity " SIZE_FORMAT "K, "
*** 3965,3975 ****
}
}
// Print information for class space and data space separately.
// This is almost the same as above.
! void MetaspaceAux::print_on(outputStream* out, Metaspace::MetadataType mdtype) {
size_t free_chunks_capacity_bytes = free_chunks_total_bytes(mdtype);
size_t capacity_bytes = capacity_bytes_slow(mdtype);
size_t used_bytes = used_bytes_slow(mdtype);
size_t free_bytes = free_bytes_slow(mdtype);
size_t used_and_free = used_bytes + free_bytes +
--- 3965,3975 ----
}
}
// Print information for class space and data space separately.
// This is almost the same as above.
! void MetaspaceUtils::print_on(outputStream* out, Metaspace::MetadataType mdtype) {
size_t free_chunks_capacity_bytes = free_chunks_total_bytes(mdtype);
size_t capacity_bytes = capacity_bytes_slow(mdtype);
size_t used_bytes = used_bytes_slow(mdtype);
size_t free_bytes = free_bytes_slow(mdtype);
size_t used_and_free = used_bytes + free_bytes +
*** 3986,3996 ****
// Accounting can only be correct if we got the values during a safepoint
assert(!SafepointSynchronize::is_at_safepoint() || used_and_free == capacity_bytes, "Accounting is wrong");
}
// Print total fragmentation for class metaspaces
! void MetaspaceAux::print_class_waste(outputStream* out) {
assert(Metaspace::using_class_space(), "class metaspace not used");
size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0;
size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_humongous_count = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
--- 3986,3996 ----
// Accounting can only be correct if we got the values during a safepoint
assert(!SafepointSynchronize::is_at_safepoint() || used_and_free == capacity_bytes, "Accounting is wrong");
}
// Print total fragmentation for class metaspaces
! void MetaspaceUtils::print_class_waste(outputStream* out) {
assert(Metaspace::using_class_space(), "class metaspace not used");
size_t cls_specialized_waste = 0, cls_small_waste = 0, cls_medium_waste = 0;
size_t cls_specialized_count = 0, cls_small_count = 0, cls_medium_count = 0, cls_humongous_count = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
*** 4013,4023 ****
cls_small_count, cls_small_waste,
cls_medium_count, cls_medium_waste, cls_humongous_count);
}
// Print total fragmentation for data and class metaspaces separately
! void MetaspaceAux::print_waste(outputStream* out) {
size_t specialized_waste = 0, small_waste = 0, medium_waste = 0;
size_t specialized_count = 0, small_count = 0, medium_count = 0, humongous_count = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
--- 4013,4023 ----
cls_small_count, cls_small_waste,
cls_medium_count, cls_medium_waste, cls_humongous_count);
}
// Print total fragmentation for data and class metaspaces separately
! void MetaspaceUtils::print_waste(outputStream* out) {
size_t specialized_waste = 0, small_waste = 0, medium_waste = 0;
size_t specialized_count = 0, small_count = 0, medium_count = 0, humongous_count = 0;
ClassLoaderDataGraphMetaspaceIterator iter;
while (iter.repeat()) {
*** 4206,4216 ****
_out->print(" Class data ");
_total_anon_class.print_on(_out, _scale);
}
}
! void MetaspaceAux::print_metadata_for_nmt(outputStream* out, size_t scale) {
const char* unit = scale_unit(scale);
out->print_cr("Metaspaces:");
out->print_cr(" Metadata space: reserved=" SIZE_FORMAT_W(10) "%s committed=" SIZE_FORMAT_W(10) "%s",
reserved_bytes(Metaspace::NonClassType) / scale, unit,
committed_bytes(Metaspace::NonClassType) / scale, unit);
--- 4206,4216 ----
_out->print(" Class data ");
_total_anon_class.print_on(_out, _scale);
}
}
! void MetaspaceUtils::print_metadata_for_nmt(outputStream* out, size_t scale) {
const char* unit = scale_unit(scale);
out->print_cr("Metaspaces:");
out->print_cr(" Metadata space: reserved=" SIZE_FORMAT_W(10) "%s committed=" SIZE_FORMAT_W(10) "%s",
reserved_bytes(Metaspace::NonClassType) / scale, unit,
committed_bytes(Metaspace::NonClassType) / scale, unit);
*** 4231,4249 ****
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);
print_waste(out);
}
// Prints an ASCII representation of the given space.
! void MetaspaceAux::print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype) {
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
const bool for_class = mdtype == Metaspace::ClassType ? true : false;
VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list();
if (vsl != NULL) {
if (for_class) {
--- 4231,4249 ----
ClassLoaderDataGraph::cld_do(&cl);
}
// Dump global metaspace things from the end of ClassLoaderDataGraph
! void MetaspaceUtils::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);
print_waste(out);
}
// Prints an ASCII representation of the given space.
! void MetaspaceUtils::print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype) {
MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
const bool for_class = mdtype == Metaspace::ClassType ? true : false;
VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list();
if (vsl != NULL) {
if (for_class) {
*** 4263,4280 ****
vsl->print_map(out);
out->cr();
}
}
! void MetaspaceAux::verify_free_chunks() {
Metaspace::chunk_manager_metadata()->verify();
if (Metaspace::using_class_space()) {
Metaspace::chunk_manager_class()->verify();
}
}
! void MetaspaceAux::verify_capacity() {
#ifdef ASSERT
size_t running_sum_capacity_bytes = capacity_bytes();
// For purposes of the running sum of capacity, verify against capacity
size_t capacity_in_use_bytes = capacity_bytes_slow();
assert(running_sum_capacity_bytes == capacity_in_use_bytes,
--- 4263,4280 ----
vsl->print_map(out);
out->cr();
}
}
! void MetaspaceUtils::verify_free_chunks() {
Metaspace::chunk_manager_metadata()->verify();
if (Metaspace::using_class_space()) {
Metaspace::chunk_manager_class()->verify();
}
}
! void MetaspaceUtils::verify_capacity() {
#ifdef ASSERT
size_t running_sum_capacity_bytes = capacity_bytes();
// For purposes of the running sum of capacity, verify against capacity
size_t capacity_in_use_bytes = capacity_bytes_slow();
assert(running_sum_capacity_bytes == capacity_in_use_bytes,
*** 4291,4301 ****
i, capacity_bytes(i), i, capacity_in_use_bytes);
}
#endif
}
! void MetaspaceAux::verify_used() {
#ifdef ASSERT
size_t running_sum_used_bytes = used_bytes();
// For purposes of the running sum of used, verify against used
size_t used_in_use_bytes = used_bytes_slow();
assert(used_bytes() == used_in_use_bytes,
--- 4291,4301 ----
i, capacity_bytes(i), i, capacity_in_use_bytes);
}
#endif
}
! void MetaspaceUtils::verify_used() {
#ifdef ASSERT
size_t running_sum_used_bytes = used_bytes();
// For purposes of the running sum of used, verify against used
size_t used_in_use_bytes = used_bytes_slow();
assert(used_bytes() == used_in_use_bytes,
*** 4312,4322 ****
i, used_bytes(i), i, used_in_use_bytes);
}
#endif
}
! void MetaspaceAux::verify_metrics() {
verify_capacity();
verify_used();
}
--- 4312,4322 ----
i, used_bytes(i), i, used_in_use_bytes);
}
#endif
}
! void MetaspaceUtils::verify_metrics() {
verify_capacity();
verify_used();
}
*** 4888,4907 ****
LogStream ls(log.debug());
loader_data->dump(&ls);
}
}
LogStream ls(log.info());
! MetaspaceAux::dump(&ls);
! MetaspaceAux::print_metaspace_map(&ls, mdtype);
ChunkManager::print_all_chunkmanagers(&ls);
}
bool out_of_compressed_class_space = false;
if (is_class_space_allocation(mdtype)) {
Metaspace* metaspace = loader_data->metaspace_non_null();
out_of_compressed_class_space =
! MetaspaceAux::committed_bytes(Metaspace::ClassType) +
(metaspace->class_chunk_size(word_size) * BytesPerWord) >
CompressedClassSpaceSize;
}
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
--- 4888,4907 ----
LogStream ls(log.debug());
loader_data->dump(&ls);
}
}
LogStream ls(log.info());
! MetaspaceUtils::dump(&ls);
! MetaspaceUtils::print_metaspace_map(&ls, mdtype);
ChunkManager::print_all_chunkmanagers(&ls);
}
bool out_of_compressed_class_space = false;
if (is_class_space_allocation(mdtype)) {
Metaspace* metaspace = loader_data->metaspace_non_null();
out_of_compressed_class_space =
! MetaspaceUtils::committed_bytes(Metaspace::ClassType) +
(metaspace->class_chunk_size(word_size) * BytesPerWord) >
CompressedClassSpaceSize;
}
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
*** 5011,5055 ****
/////////////// Unit tests ///////////////
#ifndef PRODUCT
! class TestMetaspaceAuxTest : AllStatic {
public:
static void test_reserved() {
! size_t reserved = MetaspaceAux::reserved_bytes();
assert(reserved > 0, "assert");
! size_t committed = MetaspaceAux::committed_bytes();
assert(committed <= reserved, "assert");
! size_t reserved_metadata = MetaspaceAux::reserved_bytes(Metaspace::NonClassType);
assert(reserved_metadata > 0, "assert");
assert(reserved_metadata <= reserved, "assert");
if (UseCompressedClassPointers) {
! size_t reserved_class = MetaspaceAux::reserved_bytes(Metaspace::ClassType);
assert(reserved_class > 0, "assert");
assert(reserved_class < reserved, "assert");
}
}
static void test_committed() {
! size_t committed = MetaspaceAux::committed_bytes();
assert(committed > 0, "assert");
! size_t reserved = MetaspaceAux::reserved_bytes();
assert(committed <= reserved, "assert");
! size_t committed_metadata = MetaspaceAux::committed_bytes(Metaspace::NonClassType);
assert(committed_metadata > 0, "assert");
assert(committed_metadata <= committed, "assert");
if (UseCompressedClassPointers) {
! size_t committed_class = MetaspaceAux::committed_bytes(Metaspace::ClassType);
assert(committed_class > 0, "assert");
assert(committed_class < committed, "assert");
}
}
--- 5011,5055 ----
/////////////// Unit tests ///////////////
#ifndef PRODUCT
! class TestMetaspaceUtilsTest : AllStatic {
public:
static void test_reserved() {
! size_t reserved = MetaspaceUtils::reserved_bytes();
assert(reserved > 0, "assert");
! size_t committed = MetaspaceUtils::committed_bytes();
assert(committed <= reserved, "assert");
! size_t reserved_metadata = MetaspaceUtils::reserved_bytes(Metaspace::NonClassType);
assert(reserved_metadata > 0, "assert");
assert(reserved_metadata <= reserved, "assert");
if (UseCompressedClassPointers) {
! size_t reserved_class = MetaspaceUtils::reserved_bytes(Metaspace::ClassType);
assert(reserved_class > 0, "assert");
assert(reserved_class < reserved, "assert");
}
}
static void test_committed() {
! size_t committed = MetaspaceUtils::committed_bytes();
assert(committed > 0, "assert");
! size_t reserved = MetaspaceUtils::reserved_bytes();
assert(committed <= reserved, "assert");
! size_t committed_metadata = MetaspaceUtils::committed_bytes(Metaspace::NonClassType);
assert(committed_metadata > 0, "assert");
assert(committed_metadata <= committed, "assert");
if (UseCompressedClassPointers) {
! size_t committed_class = MetaspaceUtils::committed_bytes(Metaspace::ClassType);
assert(committed_class > 0, "assert");
assert(committed_class < committed, "assert");
}
}
*** 5068,5079 ****
test_committed();
test_virtual_space_list_large_chunk();
}
};
! void TestMetaspaceAux_test() {
! TestMetaspaceAuxTest::test();
}
class TestVirtualSpaceNodeTest {
static void chunk_up(size_t words_left, size_t& num_medium_chunks,
size_t& num_small_chunks,
--- 5068,5079 ----
test_committed();
test_virtual_space_list_large_chunk();
}
};
! void TestMetaspaceUtils_test() {
! TestMetaspaceUtilsTest::test();
}
class TestVirtualSpaceNodeTest {
static void chunk_up(size_t words_left, size_t& num_medium_chunks,
size_t& num_small_chunks,
< prev index next >