< prev index next >

src/hotspot/share/memory/metaspace.cpp

Print this page




 111 
 112   if (delta <= min_delta) {
 113     delta = min_delta;
 114   } else if (delta <= max_delta) {
 115     // Don't want to hit the high water mark on the next
 116     // allocation so make the delta greater than just enough
 117     // for this allocation.
 118     delta = max_delta;
 119   } else {
 120     // This allocation is large but the next ones are probably not
 121     // so increase by the minimum.
 122     delta = delta + min_delta;
 123   }
 124 
 125   assert_is_aligned(delta, Metaspace::commit_alignment());
 126 
 127   return delta;
 128 }
 129 
 130 size_t MetaspaceGC::capacity_until_GC() {
 131   size_t value = OrderAccess::load_acquire(&_capacity_until_GC);
 132   assert(value >= MetaspaceSize, "Not initialized properly?");
 133   return value;
 134 }
 135 
 136 // Try to increase the _capacity_until_GC limit counter by v bytes.
 137 // Returns true if it succeeded. It may fail if either another thread
 138 // concurrently increased the limit or the new limit would be larger
 139 // than MaxMetaspaceSize.
 140 // On success, optionally returns new and old metaspace capacity in
 141 // new_cap_until_GC and old_cap_until_GC respectively.
 142 // On error, optionally sets can_retry to indicate whether if there is
 143 // actually enough space remaining to satisfy the request.
 144 bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC, bool* can_retry) {
 145   assert_is_aligned(v, Metaspace::commit_alignment());
 146 
 147   size_t old_capacity_until_GC = _capacity_until_GC;
 148   size_t new_value = old_capacity_until_GC + v;
 149 
 150   if (new_value < old_capacity_until_GC) {
 151     // The addition wrapped around, set new_value to aligned max value.




 111 
 112   if (delta <= min_delta) {
 113     delta = min_delta;
 114   } else if (delta <= max_delta) {
 115     // Don't want to hit the high water mark on the next
 116     // allocation so make the delta greater than just enough
 117     // for this allocation.
 118     delta = max_delta;
 119   } else {
 120     // This allocation is large but the next ones are probably not
 121     // so increase by the minimum.
 122     delta = delta + min_delta;
 123   }
 124 
 125   assert_is_aligned(delta, Metaspace::commit_alignment());
 126 
 127   return delta;
 128 }
 129 
 130 size_t MetaspaceGC::capacity_until_GC() {
 131   size_t value = Atomic::load_acquire(&_capacity_until_GC);
 132   assert(value >= MetaspaceSize, "Not initialized properly?");
 133   return value;
 134 }
 135 
 136 // Try to increase the _capacity_until_GC limit counter by v bytes.
 137 // Returns true if it succeeded. It may fail if either another thread
 138 // concurrently increased the limit or the new limit would be larger
 139 // than MaxMetaspaceSize.
 140 // On success, optionally returns new and old metaspace capacity in
 141 // new_cap_until_GC and old_cap_until_GC respectively.
 142 // On error, optionally sets can_retry to indicate whether if there is
 143 // actually enough space remaining to satisfy the request.
 144 bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC, bool* can_retry) {
 145   assert_is_aligned(v, Metaspace::commit_alignment());
 146 
 147   size_t old_capacity_until_GC = _capacity_until_GC;
 148   size_t new_value = old_capacity_until_GC + v;
 149 
 150   if (new_value < old_capacity_until_GC) {
 151     // The addition wrapped around, set new_value to aligned max value.


< prev index next >