On Tue, 7 Jun 2022 10:07:08 GMT, Yi Yang <yy...@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`. > > Yi Yang has updated the pull request incrementally with one additional commit > since the last revision: > > update
@tstuefe could you take a look at the test changes. Since we can no longer query the compressed class space individually, I think the tests may become more lenient than before. For example, memoryUsageSmallComp/TestDescription.java uses `MemoryUsageTest::checkForNotGrowing()` which monitors the used bytes in `MetaspaceBaseGC::pool.getUsage().getUsed()` - Before this PR, it checks that the usage of the compressed klass space doesn't grow. - After this PR, it will allow the compresed klass space to grow, as long as the "other" meta space shrinks by a similar amount. Is this OK? Or should we add a new whitebox API to query the compressed vs meta space? src/hotspot/share/services/management.cpp line 743: > 741: } else { > 742: // Calculate the memory usage by summing up the pools. > 743: // NonHeapUsage = CodeHeaps + Metaspace I think the new comments in this file can be removed. test/hotspot/jtreg/vmTestbase/metaspace/gc/MemoryUsageTest.java line 141: > 139: System.err.println("Usage: "); > 140: System.err.println("java [-Xms..] [-XX:MetaspaceSize=..] > [-XX:MaxMetaspaceSize=..] \\"); > 141: System.err.println(" " + > MemoryUsageTest.class.getCanonicalName()); This method can be deleted since it's no longer used. ------------- PR: https://git.openjdk.java.net/jdk/pull/8831