Example #1
0
  // low memory detection for collected memory pools.
  static inline void detect_low_memory_for_collected_pools() {
    // no-op if low memory detection not enabled
    if (!is_enabled_for_collected_pools()) {
      return;
    }
    int num_memory_pools = MemoryService::num_memory_pools();
    for (int i=0; i<num_memory_pools; i++) {
      MemoryPool* pool = MemoryService::get_memory_pool(i);

      // if low memory detection is enabled then check if the
      // current used exceeds the high threshold
      if (pool->is_collected_pool() && is_enabled(pool)) {
        size_t used = pool->used_in_bytes();
        size_t high = pool->usage_threshold()->high_threshold();
        if (used > high) {
          detect_low_memory(pool);
        }
      }
    }
  }