RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong
David Holmes
dholmes at openjdk.java.net
Fri May 27 05:34:33 UTC 2022
On Mon, 23 May 2022 07:28:41 GMT, Yi Yang <yyang at openjdk.org> wrote:
> It seems that calculation of MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong.
>
> Currently, `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)`
>
> ==> CodeHeap 'non-nmethods' 1532544 (Used)
> ==> CodeHeap 'profiled nmethods' 0
> ==> CodeHeap 'non-profiled nmethods' 13952
> ==> Metaspace 506696
> ==> Compressed Class Space 43312
> init = 7667712(7488K) used = 2096504(2047K) committed = 8454144(8256K) max = -1(-1K)
>
> In this way, getNonHeapMemoryUsage is larger than it ought to be, it should be `NonHeapUsage = CodeCache + Metaspace`.
The basic problem is that we have two non-heap pools:
- `MetaspacePool`
- consists of `ClassType` and `NonClassType` parts
- `CompressedKlassSpacePool`
but the `CompressedKlassSpacePool` is actually the "ClassType" part of the `MetaspacePool`!
I think the right fix is to just convert the `MetaspacePool` into `NonClassMetaspacePool` and only report the non-class values.
AFAICS this will only be visible via the MXBean.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8831
More information about the serviceability-dev
mailing list