On Mon, 23 May 2022 07:28:41 GMT, Yi Yang <yy...@openjdk.org> wrote:

> It seems that calculation of 
> MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong.
> 
> Currently, NonHeapUsage = CodeCache + Metaspace + CompressedClassSpace
> 
> ==> 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.

Sorry but I can't agree with this change as presented. By definition the total 
non-heap memory is the sum of all pools which identify as non-heap as per the 
specification:

"The non-heap memory consists of one or more memory pools. The used and 
committed size of the returned memory usage is the sum of those values of all 
non-heap memory pools ..."

so the existing code that sums the non-heap pools is correct. If you think 
`CompressedClassSpace` should not be counted then you need to argue for it  to 
not be "non-heap".

Cheers,
David

-------------

Changes requested by dholmes (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/8831

Reply via email to