217 GrowableArray<MemoryPool*> G1MonitoringSupport::memory_pools() {
218 GrowableArray<MemoryPool*> memory_pools(3);
219 memory_pools.append(_eden_space_pool);
220 memory_pools.append(_survivor_space_pool);
221 memory_pools.append(_old_gen_pool);
222 return memory_pools;
223 }
224
225 void G1MonitoringSupport::recalculate_sizes() {
226 assert_heap_locked_or_at_safepoint(true);
227
228 MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
229 // Recalculate all the sizes from scratch.
230
231 uint young_list_length = _g1h->young_regions_count();
232 uint survivor_list_length = _g1h->survivor_regions_count();
233 assert(young_list_length >= survivor_list_length, "invariant");
234 uint eden_list_length = young_list_length - survivor_list_length;
235 // Max length includes any potential extensions to the young gen
236 // we'll do when the GC locker is active.
237 uint young_list_max_length = _g1h->g1_policy()->young_list_max_length();
238 assert(young_list_max_length >= survivor_list_length, "invariant");
239 uint eden_list_max_length = young_list_max_length - survivor_list_length;
240
241 _overall_used = _g1h->used_unlocked();
242 _eden_space_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
243 _survivor_space_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
244 _old_gen_used = subtract_up_to_zero(_overall_used, _eden_space_used + _survivor_space_used);
245
246 // First calculate the committed sizes that can be calculated independently.
247 _survivor_space_committed = _survivor_space_used;
248 _old_gen_committed = HeapRegion::align_up_to_region_byte_size(_old_gen_used);
249
250 // Next, start with the overall committed size.
251 _overall_committed = _g1h->capacity();
252 size_t committed = _overall_committed;
253
254 // Remove the committed size we have calculated so far (for the
255 // survivor and old space).
256 assert(committed >= (_survivor_space_committed + _old_gen_committed), "sanity");
257 committed -= _survivor_space_committed + _old_gen_committed;
|
217 GrowableArray<MemoryPool*> G1MonitoringSupport::memory_pools() {
218 GrowableArray<MemoryPool*> memory_pools(3);
219 memory_pools.append(_eden_space_pool);
220 memory_pools.append(_survivor_space_pool);
221 memory_pools.append(_old_gen_pool);
222 return memory_pools;
223 }
224
225 void G1MonitoringSupport::recalculate_sizes() {
226 assert_heap_locked_or_at_safepoint(true);
227
228 MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
229 // Recalculate all the sizes from scratch.
230
231 uint young_list_length = _g1h->young_regions_count();
232 uint survivor_list_length = _g1h->survivor_regions_count();
233 assert(young_list_length >= survivor_list_length, "invariant");
234 uint eden_list_length = young_list_length - survivor_list_length;
235 // Max length includes any potential extensions to the young gen
236 // we'll do when the GC locker is active.
237 uint young_list_max_length = _g1h->policy()->young_list_max_length();
238 assert(young_list_max_length >= survivor_list_length, "invariant");
239 uint eden_list_max_length = young_list_max_length - survivor_list_length;
240
241 _overall_used = _g1h->used_unlocked();
242 _eden_space_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
243 _survivor_space_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
244 _old_gen_used = subtract_up_to_zero(_overall_used, _eden_space_used + _survivor_space_used);
245
246 // First calculate the committed sizes that can be calculated independently.
247 _survivor_space_committed = _survivor_space_used;
248 _old_gen_committed = HeapRegion::align_up_to_region_byte_size(_old_gen_used);
249
250 // Next, start with the overall committed size.
251 _overall_committed = _g1h->capacity();
252 size_t committed = _overall_committed;
253
254 // Remove the committed size we have calculated so far (for the
255 // survivor and old space).
256 assert(committed >= (_survivor_space_committed + _old_gen_committed), "sanity");
257 committed -= _survivor_space_committed + _old_gen_committed;
|