using metaspace::ChunkManager; using metaspace::MetaspaceArena; using metaspace::ArenaGrowthPolicy; using metaspace::RunningCounters; using metaspace::InternalStats;
// Allocate word_size words from Metaspace.
MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataType mdType) { if (Metaspace::is_class_space_allocation(mdType)) { return class_space_arena()->allocate(word_size);
} else { return non_class_space_arena()->allocate(word_size);
}
}
// Attempt to expand the GC threshold to be good for at least another word_size words // and allocate. Returns NULL if failure. Used during Metaspace GC.
MetaWord* ClassLoaderMetaspace::expand_and_allocate(size_t word_size, Metaspace::MetadataType mdType) {
size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord);
assert(delta_bytes > 0, "Must be");
size_t before = 0;
size_t after = 0; bool can_retry = true;
MetaWord* res; bool incremented;
// Each thread increments the HWM at most once. Even if the thread fails to increment // the HWM, an allocation is still attempted. This is because another thread must then // have incremented the HWM and therefore the allocation might still succeed. do {
incremented = MetaspaceGC::inc_capacity_until_GC(delta_bytes, &after, &before, &can_retry);
res = allocate(word_size, mdType);
} while (!incremented && res == NULL && can_retry);
if (incremented) {
Metaspace::tracer()->report_gc_threshold(before, after,
MetaspaceGCThresholdUpdater::ExpandAndAllocate); // Keeping both for now until I am sure the old variant (gc + metaspace) is not needed anymore
log_trace(gc, metaspace)("Increase capacity to GC from " SIZE_FORMAT " to " SIZE_FORMAT, before, after);
UL2(info, "GC threshold increased: " SIZE_FORMAT "->" SIZE_FORMAT ".", before, after);
}
return res;
}
// Prematurely returns a metaspace allocation to the _block_freelists // because it is not needed anymore. void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { if (Metaspace::using_class_space() && is_class) {
class_space_arena()->deallocate(ptr, word_size);
} else {
non_class_space_arena()->deallocate(ptr, word_size);
}
DEBUG_ONLY(InternalStats::inc_num_deallocs();)
}
// Update statistics. This walks all in-use chunks. void ClassLoaderMetaspace::add_to_statistics(metaspace::ClmsStats* out) const { if (non_class_space_arena() != NULL) {
non_class_space_arena()->add_to_statistics(&out->_arena_stats_nonclass);
} if (class_space_arena() != NULL) {
class_space_arena()->add_to_statistics(&out->_arena_stats_class);
}
}
// This only exists for JFR and jcmd VM.classloader_stats. We may want to // change this. Capacity as a stat is of questionable use since it may // contain committed and uncommitted areas. For now we do this to maintain // backward compatibility with JFR. void ClassLoaderMetaspace::calculate_jfr_stats(size_t* p_used_bytes, size_t* p_capacity_bytes) const { // Implement this using the standard statistics objects.
size_t used_c = 0, cap_c = 0, used_nc = 0, cap_nc = 0; if (non_class_space_arena() != NULL) {
non_class_space_arena()->usage_numbers(&used_nc, NULL, &cap_nc);
} if (class_space_arena() != NULL) {
class_space_arena()->usage_numbers(&used_c, NULL, &cap_c);
} if (p_used_bytes != NULL) {
*p_used_bytes = used_c + used_nc;
} if (p_capacity_bytes != NULL) {
*p_capacity_bytes = cap_c + cap_nc;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-09-05)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.