mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
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
This commit is contained in:
parent
820ae7109e
commit
1653234dda
5 changed files with 28 additions and 11 deletions
|
@ -370,7 +370,7 @@ bool RSHashTable::contains_card(RegionIdx_t region_index, CardIdx_t card_index)
|
|||
}
|
||||
|
||||
size_t RSHashTable::mem_size() const {
|
||||
return sizeof(this) +
|
||||
return sizeof(RSHashTable) +
|
||||
capacity() * (SparsePRTEntry::size() + sizeof(int));
|
||||
}
|
||||
|
||||
|
@ -472,7 +472,7 @@ SparsePRT::~SparsePRT() {
|
|||
size_t SparsePRT::mem_size() const {
|
||||
// We ignore "_cur" here, because it either = _next, or else it is
|
||||
// on the deleted list.
|
||||
return sizeof(this) + _next->mem_size();
|
||||
return sizeof(SparsePRT) + _next->mem_size();
|
||||
}
|
||||
|
||||
bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue