1062 // gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The |
1062 // gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The |
1063 // metaspace policy uses those as the small and large steps for the HWM. |
1063 // metaspace policy uses those as the small and large steps for the HWM. |
1064 // |
1064 // |
1065 // After the GC the compute_new_size() for MetaspaceGC is called to |
1065 // After the GC the compute_new_size() for MetaspaceGC is called to |
1066 // resize the capacity of the metaspaces. The current implementation |
1066 // resize the capacity of the metaspaces. The current implementation |
1067 // is based on the flags MinHeapFreeRatio and MaxHeapFreeRatio used |
1067 // is based on the flags MinMetaspaceFreeRatio and MaxHeapFreeRatio used |
1068 // to resize the Java heap by some GC's. New flags can be implemented |
1068 // to resize the Java heap by some GC's. New flags can be implemented |
1069 // if really needed. MinHeapFreeRatio is used to calculate how much |
1069 // if really needed. MinHeapFreeRatio is used to calculate how much |
1070 // free space is desirable in the metaspace capacity to decide how much |
1070 // free space is desirable in the metaspace capacity to decide how much |
1071 // to increase the HWM. MaxHeapFreeRatio is used to decide how much |
1071 // to increase the HWM. MaxMetaspaceFreeRatio is used to decide how much |
1072 // free space is desirable in the metaspace capacity before decreasing |
1072 // free space is desirable in the metaspace capacity before decreasing |
1073 // the HWM. |
1073 // the HWM. |
1074 |
1074 |
1075 // Calculate the amount to increase the high water mark (HWM). |
1075 // Calculate the amount to increase the high water mark (HWM). |
1076 // Increase by a minimum amount (MinMetaspaceExpansion) so that |
1076 // Increase by a minimum amount (MinMetaspaceExpansion) so that |
1164 // Check to see if these two can be calculated without walking the CLDG |
1164 // Check to see if these two can be calculated without walking the CLDG |
1165 size_t used_after_gc = vsl->used_bytes_sum(); |
1165 size_t used_after_gc = vsl->used_bytes_sum(); |
1166 size_t capacity_until_GC = vsl->capacity_bytes_sum(); |
1166 size_t capacity_until_GC = vsl->capacity_bytes_sum(); |
1167 size_t free_after_gc = capacity_until_GC - used_after_gc; |
1167 size_t free_after_gc = capacity_until_GC - used_after_gc; |
1168 |
1168 |
1169 const double minimum_free_percentage = MinHeapFreeRatio / 100.0; |
1169 const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; |
1170 const double maximum_used_percentage = 1.0 - minimum_free_percentage; |
1170 const double maximum_used_percentage = 1.0 - minimum_free_percentage; |
1171 |
1171 |
1172 const double min_tmp = used_after_gc / maximum_used_percentage; |
1172 const double min_tmp = used_after_gc / maximum_used_percentage; |
1173 size_t minimum_desired_capacity = |
1173 size_t minimum_desired_capacity = |
1174 (size_t)MIN2(min_tmp, double(max_uintx)); |
1174 (size_t)MIN2(min_tmp, double(max_uintx)); |
1230 size_t max_shrink_words = capacity_until_GC - minimum_desired_capacity; |
1230 size_t max_shrink_words = capacity_until_GC - minimum_desired_capacity; |
1231 assert(max_shrink_words >= 0, err_msg("max_shrink_words " SIZE_FORMAT, |
1231 assert(max_shrink_words >= 0, err_msg("max_shrink_words " SIZE_FORMAT, |
1232 max_shrink_words)); |
1232 max_shrink_words)); |
1233 |
1233 |
1234 // Should shrinking be considered? |
1234 // Should shrinking be considered? |
1235 if (MaxHeapFreeRatio < 100) { |
1235 if (MaxMetaspaceFreeRatio < 100) { |
1236 const double maximum_free_percentage = MaxHeapFreeRatio / 100.0; |
1236 const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0; |
1237 const double minimum_used_percentage = 1.0 - maximum_free_percentage; |
1237 const double minimum_used_percentage = 1.0 - maximum_free_percentage; |
1238 const double max_tmp = used_after_gc / minimum_used_percentage; |
1238 const double max_tmp = used_after_gc / minimum_used_percentage; |
1239 size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); |
1239 size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx)); |
1240 maximum_desired_capacity = MAX2(maximum_desired_capacity, |
1240 maximum_desired_capacity = MAX2(maximum_desired_capacity, |
1241 MetaspaceSize); |
1241 MetaspaceSize); |