< prev index next >

src/hotspot/share/memory/metaspace.cpp

Print this page

        

*** 147,156 **** --- 147,162 ---- if (old_capacity_until_GC != prev_value) { return false; } + // Check after the increment that we did not go over the maximum. + // We can not do this earlier due to potential races. + assert(new_value <= MaxMetaspaceSize, + "new_value: " SIZE_FORMAT " > MaxMetaspaceSize: " SIZE_FORMAT, + new_value, MaxMetaspaceSize); + if (new_cap_until_GC != NULL) { *new_cap_until_GC = new_value; } if (old_cap_until_GC != NULL) { *old_cap_until_GC = old_capacity_until_GC;
*** 234,244 **** const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; const double maximum_used_percentage = 1.0 - minimum_free_percentage; const double min_tmp = used_after_gc / maximum_used_percentage; size_t minimum_desired_capacity = ! (size_t)MIN2(min_tmp, double(max_uintx)); // Don't shrink less than the initial generation size minimum_desired_capacity = MAX2(minimum_desired_capacity, MetaspaceSize); log_trace(gc, metaspace)("MetaspaceGC::compute_new_size: "); --- 240,250 ---- const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; const double maximum_used_percentage = 1.0 - minimum_free_percentage; const double min_tmp = used_after_gc / maximum_used_percentage; size_t minimum_desired_capacity = ! (size_t)MIN2(min_tmp, double(MaxMetaspaceSize)); // Don't shrink less than the initial generation size minimum_desired_capacity = MAX2(minimum_desired_capacity, MetaspaceSize); log_trace(gc, metaspace)("MetaspaceGC::compute_new_size: ");
*** 281,291 **** // Should shrinking be considered? if (MaxMetaspaceFreeRatio < 100) { const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0; const double minimum_used_percentage = 1.0 - maximum_free_percentage; const double max_tmp = used_after_gc / minimum_used_percentage; ! size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); maximum_desired_capacity = MAX2(maximum_desired_capacity, MetaspaceSize); log_trace(gc, metaspace)(" maximum_free_percentage: %6.2f minimum_used_percentage: %6.2f", maximum_free_percentage, minimum_used_percentage); log_trace(gc, metaspace)(" minimum_desired_capacity: %6.1fKB maximum_desired_capacity: %6.1fKB", --- 287,297 ---- // Should shrinking be considered? if (MaxMetaspaceFreeRatio < 100) { const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0; const double minimum_used_percentage = 1.0 - maximum_free_percentage; const double max_tmp = used_after_gc / minimum_used_percentage; ! size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(MaxMetaspaceSize)); maximum_desired_capacity = MAX2(maximum_desired_capacity, MetaspaceSize); log_trace(gc, metaspace)(" maximum_free_percentage: %6.2f minimum_used_percentage: %6.2f", maximum_free_percentage, minimum_used_percentage); log_trace(gc, metaspace)(" minimum_desired_capacity: %6.1fKB maximum_desired_capacity: %6.1fKB",
*** 1475,1484 **** --- 1481,1493 ---- // 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 { + if (MetaspaceGC::capacity_until_GC() + delta_bytes > MaxMetaspaceSize) { + return NULL; + } incremented = MetaspaceGC::inc_capacity_until_GC(delta_bytes, &after, &before); res = allocate(word_size, mdtype); } while (!incremented && res == NULL); if (incremented) {
< prev index next >