| 243 | } |
| 244 | |
| 245 | bool SoftLimitExceeded(double* current_capacity_pct) { |
| 246 | InitLimits(); |
| 247 | int64_t consumption = CurrentConsumption(); |
| 248 | // Did we exceed the actual limit? |
| 249 | if (consumption > g_hard_limit) { |
| 250 | if (current_capacity_pct) { |
| 251 | *current_capacity_pct = static_cast<double>(consumption) / g_hard_limit * 100; |
| 252 | } |
| 253 | return true; |
| 254 | } |
| 255 | |
| 256 | // No soft limit defined. |
| 257 | if (g_hard_limit == g_soft_limit) { |
| 258 | return false; |
| 259 | } |
| 260 | |
| 261 | // Are we under the soft limit threshold? |
| 262 | if (consumption < g_soft_limit) { |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | // We're over the threshold; were we randomly chosen to be over the soft limit? |
| 267 | if (consumption + g_rand->Uniform64(g_hard_limit - g_soft_limit) > g_hard_limit) { |
| 268 | if (current_capacity_pct) { |
| 269 | *current_capacity_pct = static_cast<double>(consumption) / g_hard_limit * 100; |
| 270 | } |
| 271 | return true; |
| 272 | } |
| 273 | return false; |
| 274 | } |
| 275 | |
| 276 | void MaybeGCAfterRelease(int64_t released_bytes) { |
| 277 | #ifdef TCMALLOC_ENABLED |
nothing calls this directly
no test coverage detected