comparison src/share/vm/gc_implementation/g1/sparsePRT.cpp @ 20218:828056cf311f

8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname) Summary: A few locations in the code use sizeof(this) which returns the size of the pointer instead of sizeof(classname) which returns the size of the sum of its members. This change fixes these errors and adds a few tests. Reviewed-by: mgerdin, brutisso
author tschatzl
date Mon, 21 Jul 2014 09:40:19 +0200
parents 55fb97c4c58d
children a8ea2f110d87
comparison
equal deleted inserted replaced
20217:6b52700a896b 20218:828056cf311f
368 SparsePRTEntry* e = entry_for_region_ind(region_index); 368 SparsePRTEntry* e = entry_for_region_ind(region_index);
369 return (e != NULL && e->contains_card(card_index)); 369 return (e != NULL && e->contains_card(card_index));
370 } 370 }
371 371
372 size_t RSHashTable::mem_size() const { 372 size_t RSHashTable::mem_size() const {
373 return sizeof(this) + 373 return sizeof(RSHashTable) +
374 capacity() * (SparsePRTEntry::size() + sizeof(int)); 374 capacity() * (SparsePRTEntry::size() + sizeof(int));
375 } 375 }
376 376
377 // ---------------------------------------------------------------------- 377 // ----------------------------------------------------------------------
378 378
470 470
471 471
472 size_t SparsePRT::mem_size() const { 472 size_t SparsePRT::mem_size() const {
473 // We ignore "_cur" here, because it either = _next, or else it is 473 // We ignore "_cur" here, because it either = _next, or else it is
474 // on the deleted list. 474 // on the deleted list.
475 return sizeof(this) + _next->mem_size(); 475 return sizeof(SparsePRT) + _next->mem_size();
476 } 476 }
477 477
478 bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) { 478 bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) {
479 #if SPARSE_PRT_VERBOSE 479 #if SPARSE_PRT_VERBOSE
480 gclog_or_tty->print_cr(" Adding card %d from region %d to region %u sparse.", 480 gclog_or_tty->print_cr(" Adding card %d from region %d to region %u sparse.",