mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +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
|
@ -84,7 +84,7 @@ void G1CodeRootChunkManager::purge_chunks(size_t keep_ratio) {
|
|||
}
|
||||
|
||||
size_t G1CodeRootChunkManager::static_mem_size() {
|
||||
return sizeof(this);
|
||||
return sizeof(G1CodeRootChunkManager);
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +116,7 @@ void G1CodeRootSet::purge_chunks(size_t keep_ratio) {
|
|||
_default_chunk_manager.purge_chunks(keep_ratio);
|
||||
}
|
||||
|
||||
size_t G1CodeRootSet::static_mem_size() {
|
||||
size_t G1CodeRootSet::free_chunks_static_mem_size() {
|
||||
return _default_chunk_manager.static_mem_size();
|
||||
}
|
||||
|
||||
|
@ -213,8 +213,12 @@ void G1CodeRootSet::nmethods_do(CodeBlobClosure* blk) const {
|
|||
}
|
||||
}
|
||||
|
||||
size_t G1CodeRootSet::static_mem_size() {
|
||||
return sizeof(G1CodeRootSet);
|
||||
}
|
||||
|
||||
size_t G1CodeRootSet::mem_size() {
|
||||
return sizeof(this) + _list.count() * _list.size();
|
||||
return G1CodeRootSet::static_mem_size() + _list.count() * _list.size();
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
@ -224,6 +228,9 @@ void G1CodeRootSet::test() {
|
|||
|
||||
assert(mgr.num_chunks_handed_out() == 0, "Must not have handed out chunks yet");
|
||||
|
||||
assert(G1CodeRootChunkManager::static_mem_size() > sizeof(void*),
|
||||
err_msg("The chunk manager's static memory usage seems too small, is only "SIZE_FORMAT" bytes.", G1CodeRootChunkManager::static_mem_size()));
|
||||
|
||||
// The number of chunks that we allocate for purge testing.
|
||||
size_t const num_chunks = 10;
|
||||
|
||||
|
@ -231,6 +238,9 @@ void G1CodeRootSet::test() {
|
|||
G1CodeRootSet set1(&mgr);
|
||||
assert(set1.is_empty(), "Code root set must be initially empty but is not.");
|
||||
|
||||
assert(G1CodeRootSet::static_mem_size() > sizeof(void*),
|
||||
err_msg("The code root set's static memory usage seems too small, is only "SIZE_FORMAT" bytes", G1CodeRootSet::static_mem_size()));
|
||||
|
||||
set1.add((nmethod*)1);
|
||||
assert(mgr.num_chunks_handed_out() == 1,
|
||||
err_msg("Must have allocated and handed out one chunk, but handed out "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue