JDK-8040792 : G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-04-17
  • Updated: 2015-01-21
  • Resolved: 2014-04-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u40Fixed 9 b12Fixed
Related Reports
Relates :  
After JDK-8038930 the calculation of the static memory used by the code root chunk manager is wrong: instead of

 86 size_t G1CodeRootChunkManager::static_mem_size() {
 87   return sizeof(this);
 88 }

Also in other places the code uses sizeof(this) instead of sizeof(class name), e.g.

$ grep -r "sizeof(this)" src/share/vm/gc_implementation/g1/
src/share/vm/gc_implementation/g1/sparsePRT.cpp:  return sizeof(this) +
src/share/vm/gc_implementation/g1/sparsePRT.cpp:  return sizeof(this) +_next->mem_size();
src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp:  return sizeof(this);
src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp:  return sizeof(this) + _list.count() * _list.size();
src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp:      + (sizeof(this) - sizeof(OtherRegionsTable))
src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp:    return sizeof(this) + _bm.size_in_words() * HeapWordSize;

All these terms are wrong, should use sizeof(*this) or sizeof(class name).

Fix this.