1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
170 void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) {
171 // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC.
172 _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
173 _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
174 _managers_list->append(_minor_gc_manager);
175 _managers_list->append(_major_gc_manager);
176
177 add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
178 add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
179 }
180
181 void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) {
182 assert(UseG1GC, "sanity");
183
184 _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager();
185 _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
186 _managers_list->append(_minor_gc_manager);
187 _managers_list->append(_major_gc_manager);
188
189 add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
190 add_g1OldGen_memory_pool(g1h, _major_gc_manager);
191 }
192 #endif // INCLUDE_ALL_GCS
193
194 MemoryPool* MemoryService::add_gen(Generation* gen,
195 const char* name,
196 bool is_heap,
197 bool support_usage_threshold) {
198
199 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
200 GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
201 _pools_list->append(pool);
202 return (MemoryPool*) pool;
203 }
204
205 MemoryPool* MemoryService::add_space(ContiguousSpace* space,
206 const char* name,
207 bool is_heap,
208 size_t max_size,
209 bool support_usage_threshold) {
210 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
224
225 _pools_list->append(pool);
226 return (MemoryPool*) pool;
227 }
228
229 #if INCLUDE_ALL_GCS
230 MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space,
231 const char* name,
232 bool is_heap,
233 size_t max_size,
234 bool support_usage_threshold) {
235 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
236 CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold);
237 _pools_list->append(pool);
238 return (MemoryPool*) pool;
239 }
240 #endif // INCLUDE_ALL_GCS
241
242 // Add memory pool(s) for one generation
243 void MemoryService::add_generation_memory_pool(Generation* gen,
244 MemoryManager* major_mgr,
245 MemoryManager* minor_mgr) {
246 guarantee(gen != NULL, "No generation for memory pool");
247 Generation::Name kind = gen->kind();
248 int index = _pools_list->length();
249
250 switch (kind) {
251 case Generation::DefNew: {
252 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
253 DefNewGeneration* young_gen = (DefNewGeneration*) gen;
254 // Add a memory pool for each space and young gen doesn't
255 // support low memory detection as it is expected to get filled up.
256 MemoryPool* eden = add_space(young_gen->eden(),
257 "Eden Space",
258 true, /* is_heap */
259 young_gen->max_eden_size(),
260 false /* support_usage_threshold */);
261 MemoryPool* survivor = add_survivor_spaces(young_gen,
262 "Survivor Space",
263 true, /* is_heap */
264 young_gen->max_survivor_size(),
265 false /* support_usage_threshold */);
315
316 default:
317 assert(false, "should not reach here");
318 // no memory pool added for others
319 break;
320 }
321
322 assert(major_mgr != NULL, "Should have at least one manager");
323 // Link managers and the memory pools together
324 for (int i = index; i < _pools_list->length(); i++) {
325 MemoryPool* pool = _pools_list->at(i);
326 major_mgr->add_pool(pool);
327 if (minor_mgr != NULL) {
328 minor_mgr->add_pool(pool);
329 }
330 }
331 }
332
333
334 #if INCLUDE_ALL_GCS
335 void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) {
336 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
337
338 // Add a memory pool for each space and young gen doesn't
339 // support low memory detection as it is expected to get filled up.
340 EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen,
341 gen->eden_space(),
342 "PS Eden Space",
343 MemoryPool::Heap,
344 false /* support_usage_threshold */);
345
346 SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(gen,
347 "PS Survivor Space",
348 MemoryPool::Heap,
349 false /* support_usage_threshold */);
350
351 major_mgr->add_pool(eden);
352 major_mgr->add_pool(survivor);
353 minor_mgr->add_pool(eden);
354 minor_mgr->add_pool(survivor);
355 _pools_list->append(eden);
356 _pools_list->append(survivor);
357 }
358
359 void MemoryService::add_psOld_memory_pool(PSOldGen* gen, MemoryManager* mgr) {
360 PSGenerationPool* old_gen = new PSGenerationPool(gen,
361 "PS Old Gen",
362 MemoryPool::Heap,
363 true /* support_usage_threshold */);
364 mgr->add_pool(old_gen);
365 _pools_list->append(old_gen);
366 }
367
368 void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
369 MemoryManager* major_mgr,
370 MemoryManager* minor_mgr) {
371 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
372
373 G1EdenPool* eden = new G1EdenPool(g1h);
374 G1SurvivorPool* survivor = new G1SurvivorPool(g1h);
375
376 major_mgr->add_pool(eden);
377 major_mgr->add_pool(survivor);
378 minor_mgr->add_pool(eden);
379 minor_mgr->add_pool(survivor);
380 _pools_list->append(eden);
381 _pools_list->append(survivor);
382 }
383
384 void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
385 MemoryManager* mgr) {
386 assert(mgr != NULL, "should have one manager");
387
388 G1OldGenPool* old_gen = new G1OldGenPool(g1h);
389 mgr->add_pool(old_gen);
390 _pools_list->append(old_gen);
391 }
392 #endif // INCLUDE_ALL_GCS
393
394 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) {
395 _code_heap_pool = new CodeHeapPool(heap,
396 "Code Cache",
397 true /* support_usage_threshold */);
398 MemoryManager* mgr = MemoryManager::get_code_cache_memory_manager();
399 mgr->add_pool(_code_heap_pool);
400
401 _pools_list->append(_code_heap_pool);
402 _managers_list->append(mgr);
403 }
404
405 void MemoryService::add_metaspace_memory_pools() {
406 MemoryManager* mgr = MemoryManager::get_metaspace_memory_manager();
407
408 _metaspace_pool = new MetaspacePool();
409 mgr->add_pool(_metaspace_pool);
467 if (fullGC) {
468 mgr = _major_gc_manager;
469 } else {
470 mgr = _minor_gc_manager;
471 }
472 assert(mgr->is_gc_memory_manager(), "Sanity check");
473 mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime);
474
475 // Track the peak memory usage when GC begins
476 if (recordPeakUsage) {
477 for (int i = 0; i < _pools_list->length(); i++) {
478 MemoryPool* pool = _pools_list->at(i);
479 pool->record_peak_memory_usage();
480 }
481 }
482 }
483
484 void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage,
485 bool recordAccumulatedGCTime,
486 bool recordGCEndTime, bool countCollection,
487 GCCause::Cause cause) {
488
489 GCMemoryManager* mgr;
490 if (fullGC) {
491 mgr = (GCMemoryManager*) _major_gc_manager;
492 } else {
493 mgr = (GCMemoryManager*) _minor_gc_manager;
494 }
495 assert(mgr->is_gc_memory_manager(), "Sanity check");
496
497 // register the GC end statistics and memory usage
498 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
499 countCollection, cause);
500 }
501
502 void MemoryService::oops_do(OopClosure* f) {
503 int i;
504
505 for (i = 0; i < _pools_list->length(); i++) {
506 MemoryPool* pool = _pools_list->at(i);
507 pool->oops_do(f);
508 }
509 for (i = 0; i < _managers_list->length(); i++) {
510 MemoryManager* mgr = _managers_list->at(i);
511 mgr->oops_do(f);
512 }
513 }
514
515 bool MemoryService::set_verbose(bool verbose) {
516 MutexLocker m(Management_lock);
517 // verbose will be set to the previous value
518 bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, Flag::MANAGEMENT);
519 assert(succeed, "Setting PrintGC flag fails");
556 switch (kind) {
557 case Generation::DefNew:
558 #if INCLUDE_ALL_GCS
559 case Generation::ParNew:
560 case Generation::ASParNew:
561 #endif // INCLUDE_ALL_GCS
562 _fullGC=false;
563 break;
564 case Generation::MarkSweepCompact:
565 #if INCLUDE_ALL_GCS
566 case Generation::ConcurrentMarkSweep:
567 case Generation::ASConcurrentMarkSweep:
568 #endif // INCLUDE_ALL_GCS
569 _fullGC=true;
570 break;
571 default:
572 assert(false, "Unrecognized gc generation kind.");
573 }
574 // this has to be called in a stop the world pause and represent
575 // an entire gc pause, start to finish:
576 initialize(_fullGC, cause,true, true, true, true, true, true, true);
577 }
578 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
579 GCCause::Cause cause,
580 bool recordGCBeginTime,
581 bool recordPreGCUsage,
582 bool recordPeakUsage,
583 bool recordPostGCUsage,
584 bool recordAccumulatedGCTime,
585 bool recordGCEndTime,
586 bool countCollection) {
587 initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
588 recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
589 countCollection);
590 }
591
592 // for a subclass to create then initialize an instance before invoking
593 // the MemoryService
594 void TraceMemoryManagerStats::initialize(bool fullGC,
595 GCCause::Cause cause,
596 bool recordGCBeginTime,
597 bool recordPreGCUsage,
598 bool recordPeakUsage,
599 bool recordPostGCUsage,
600 bool recordAccumulatedGCTime,
601 bool recordGCEndTime,
602 bool countCollection) {
603 _fullGC = fullGC;
604 _recordGCBeginTime = recordGCBeginTime;
605 _recordPreGCUsage = recordPreGCUsage;
606 _recordPeakUsage = recordPeakUsage;
607 _recordPostGCUsage = recordPostGCUsage;
608 _recordAccumulatedGCTime = recordAccumulatedGCTime;
609 _recordGCEndTime = recordGCEndTime;
610 _countCollection = countCollection;
611 _cause = cause;
612
613 MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime,
614 _recordPreGCUsage, _recordPeakUsage);
615 }
616
617 TraceMemoryManagerStats::~TraceMemoryManagerStats() {
618 MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
619 _recordGCEndTime, _countCollection, _cause);
620 }
|
1 /*
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
170 void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) {
171 // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC.
172 _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
173 _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
174 _managers_list->append(_minor_gc_manager);
175 _managers_list->append(_major_gc_manager);
176
177 add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
178 add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
179 }
180
181 void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) {
182 assert(UseG1GC, "sanity");
183
184 _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager();
185 _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
186 _managers_list->append(_minor_gc_manager);
187 _managers_list->append(_major_gc_manager);
188
189 add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
190 add_g1OldGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
191 }
192 #endif // INCLUDE_ALL_GCS
193
194 MemoryPool* MemoryService::add_gen(Generation* gen,
195 const char* name,
196 bool is_heap,
197 bool support_usage_threshold) {
198
199 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
200 GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
201 _pools_list->append(pool);
202 return (MemoryPool*) pool;
203 }
204
205 MemoryPool* MemoryService::add_space(ContiguousSpace* space,
206 const char* name,
207 bool is_heap,
208 size_t max_size,
209 bool support_usage_threshold) {
210 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
224
225 _pools_list->append(pool);
226 return (MemoryPool*) pool;
227 }
228
229 #if INCLUDE_ALL_GCS
230 MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space,
231 const char* name,
232 bool is_heap,
233 size_t max_size,
234 bool support_usage_threshold) {
235 MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
236 CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold);
237 _pools_list->append(pool);
238 return (MemoryPool*) pool;
239 }
240 #endif // INCLUDE_ALL_GCS
241
242 // Add memory pool(s) for one generation
243 void MemoryService::add_generation_memory_pool(Generation* gen,
244 GCMemoryManager* major_mgr,
245 GCMemoryManager* minor_mgr) {
246 guarantee(gen != NULL, "No generation for memory pool");
247 Generation::Name kind = gen->kind();
248 int index = _pools_list->length();
249
250 switch (kind) {
251 case Generation::DefNew: {
252 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
253 DefNewGeneration* young_gen = (DefNewGeneration*) gen;
254 // Add a memory pool for each space and young gen doesn't
255 // support low memory detection as it is expected to get filled up.
256 MemoryPool* eden = add_space(young_gen->eden(),
257 "Eden Space",
258 true, /* is_heap */
259 young_gen->max_eden_size(),
260 false /* support_usage_threshold */);
261 MemoryPool* survivor = add_survivor_spaces(young_gen,
262 "Survivor Space",
263 true, /* is_heap */
264 young_gen->max_survivor_size(),
265 false /* support_usage_threshold */);
315
316 default:
317 assert(false, "should not reach here");
318 // no memory pool added for others
319 break;
320 }
321
322 assert(major_mgr != NULL, "Should have at least one manager");
323 // Link managers and the memory pools together
324 for (int i = index; i < _pools_list->length(); i++) {
325 MemoryPool* pool = _pools_list->at(i);
326 major_mgr->add_pool(pool);
327 if (minor_mgr != NULL) {
328 minor_mgr->add_pool(pool);
329 }
330 }
331 }
332
333
334 #if INCLUDE_ALL_GCS
335 void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen,
336 GCMemoryManager* major_mgr,
337 GCMemoryManager* minor_mgr) {
338 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
339
340 // Add a memory pool for each space and young gen doesn't
341 // support low memory detection as it is expected to get filled up.
342 EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen,
343 gen->eden_space(),
344 "PS Eden Space",
345 MemoryPool::Heap,
346 false /* support_usage_threshold */);
347
348 SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(gen,
349 "PS Survivor Space",
350 MemoryPool::Heap,
351 false /* support_usage_threshold */);
352
353 major_mgr->add_pool(eden);
354 major_mgr->add_pool(survivor);
355 minor_mgr->add_pool(eden);
356 minor_mgr->add_pool(survivor);
357 _pools_list->append(eden);
358 _pools_list->append(survivor);
359 }
360
361 void MemoryService::add_psOld_memory_pool(PSOldGen* gen, GCMemoryManager* mgr) {
362 PSGenerationPool* old_gen = new PSGenerationPool(gen,
363 "PS Old Gen",
364 MemoryPool::Heap,
365 true /* support_usage_threshold */);
366 mgr->add_pool(old_gen);
367 _pools_list->append(old_gen);
368 }
369
370 void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
371 GCMemoryManager* major_mgr,
372 GCMemoryManager* minor_mgr) {
373 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
374
375 G1EdenPool* eden = new G1EdenPool(g1h);
376 G1SurvivorPool* survivor = new G1SurvivorPool(g1h);
377
378 major_mgr->add_pool(eden);
379 major_mgr->add_pool(survivor);
380 minor_mgr->add_pool(eden);
381 minor_mgr->add_pool(survivor);
382 _pools_list->append(eden);
383 _pools_list->append(survivor);
384 }
385
386 void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
387 GCMemoryManager* major_mgr,
388 GCMemoryManager* minor_mgr) {
389 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
390
391 G1OldGenPool* old_gen = new G1OldGenPool(g1h);
392 major_mgr->add_pool(old_gen);
393 minor_mgr->add_pool(old_gen, false /* always_affected_by_gc */);
394 _pools_list->append(old_gen);
395 }
396 #endif // INCLUDE_ALL_GCS
397
398 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) {
399 _code_heap_pool = new CodeHeapPool(heap,
400 "Code Cache",
401 true /* support_usage_threshold */);
402 MemoryManager* mgr = MemoryManager::get_code_cache_memory_manager();
403 mgr->add_pool(_code_heap_pool);
404
405 _pools_list->append(_code_heap_pool);
406 _managers_list->append(mgr);
407 }
408
409 void MemoryService::add_metaspace_memory_pools() {
410 MemoryManager* mgr = MemoryManager::get_metaspace_memory_manager();
411
412 _metaspace_pool = new MetaspacePool();
413 mgr->add_pool(_metaspace_pool);
471 if (fullGC) {
472 mgr = _major_gc_manager;
473 } else {
474 mgr = _minor_gc_manager;
475 }
476 assert(mgr->is_gc_memory_manager(), "Sanity check");
477 mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime);
478
479 // Track the peak memory usage when GC begins
480 if (recordPeakUsage) {
481 for (int i = 0; i < _pools_list->length(); i++) {
482 MemoryPool* pool = _pools_list->at(i);
483 pool->record_peak_memory_usage();
484 }
485 }
486 }
487
488 void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage,
489 bool recordAccumulatedGCTime,
490 bool recordGCEndTime, bool countCollection,
491 GCCause::Cause cause,
492 bool allMemoryPoolsAffected) {
493
494 GCMemoryManager* mgr;
495 if (fullGC) {
496 mgr = (GCMemoryManager*) _major_gc_manager;
497 } else {
498 mgr = (GCMemoryManager*) _minor_gc_manager;
499 }
500 assert(mgr->is_gc_memory_manager(), "Sanity check");
501
502 // register the GC end statistics and memory usage
503 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
504 countCollection, cause, allMemoryPoolsAffected);
505 }
506
507 void MemoryService::oops_do(OopClosure* f) {
508 int i;
509
510 for (i = 0; i < _pools_list->length(); i++) {
511 MemoryPool* pool = _pools_list->at(i);
512 pool->oops_do(f);
513 }
514 for (i = 0; i < _managers_list->length(); i++) {
515 MemoryManager* mgr = _managers_list->at(i);
516 mgr->oops_do(f);
517 }
518 }
519
520 bool MemoryService::set_verbose(bool verbose) {
521 MutexLocker m(Management_lock);
522 // verbose will be set to the previous value
523 bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, Flag::MANAGEMENT);
524 assert(succeed, "Setting PrintGC flag fails");
561 switch (kind) {
562 case Generation::DefNew:
563 #if INCLUDE_ALL_GCS
564 case Generation::ParNew:
565 case Generation::ASParNew:
566 #endif // INCLUDE_ALL_GCS
567 _fullGC=false;
568 break;
569 case Generation::MarkSweepCompact:
570 #if INCLUDE_ALL_GCS
571 case Generation::ConcurrentMarkSweep:
572 case Generation::ASConcurrentMarkSweep:
573 #endif // INCLUDE_ALL_GCS
574 _fullGC=true;
575 break;
576 default:
577 assert(false, "Unrecognized gc generation kind.");
578 }
579 // this has to be called in a stop the world pause and represent
580 // an entire gc pause, start to finish:
581 initialize(_fullGC, cause, true, true, true, true, true, true, true, true);
582 }
583 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
584 GCCause::Cause cause,
585 bool allMemoryPoolsAffected,
586 bool recordGCBeginTime,
587 bool recordPreGCUsage,
588 bool recordPeakUsage,
589 bool recordPostGCUsage,
590 bool recordAccumulatedGCTime,
591 bool recordGCEndTime,
592 bool countCollection) {
593 initialize(fullGC, cause, allMemoryPoolsAffected,
594 recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
595 recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
596 countCollection);
597 }
598
599 // for a subclass to create then initialize an instance before invoking
600 // the MemoryService
601 void TraceMemoryManagerStats::initialize(bool fullGC,
602 GCCause::Cause cause,
603 bool allMemoryPoolsAffected,
604 bool recordGCBeginTime,
605 bool recordPreGCUsage,
606 bool recordPeakUsage,
607 bool recordPostGCUsage,
608 bool recordAccumulatedGCTime,
609 bool recordGCEndTime,
610 bool countCollection) {
611 _fullGC = fullGC;
612 _allMemoryPoolsAffected = allMemoryPoolsAffected;
613 _recordGCBeginTime = recordGCBeginTime;
614 _recordPreGCUsage = recordPreGCUsage;
615 _recordPeakUsage = recordPeakUsage;
616 _recordPostGCUsage = recordPostGCUsage;
617 _recordAccumulatedGCTime = recordAccumulatedGCTime;
618 _recordGCEndTime = recordGCEndTime;
619 _countCollection = countCollection;
620 _cause = cause;
621
622 MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime,
623 _recordPreGCUsage, _recordPeakUsage);
624 }
625
626 TraceMemoryManagerStats::~TraceMemoryManagerStats() {
627 MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
628 _recordGCEndTime, _countCollection, _cause, _allMemoryPoolsAffected);
629 }
|