RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong
Yi Yang
yyang at openjdk.java.net
Fri May 27 06:29:39 UTC 2022
On Fri, 27 May 2022 06:22:36 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> I think the right fix is to just convert the MetaspacePool into NonClassMetaspacePool and only report the non-class values.
Yes, it's okay for me. But I have another concern.
The compressed class pool is not directly used by other VM components. However, memory pools are exposed via java management APIs. At JDK level, users could obtain memory pools and choose a specified pool by name. If adapting the first solution, I guess it's somewhat strange for users to understand what is `Non Class Space`:
private static MemoryPoolMXBean getMemoryPool(String name) {
List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean pool : pools) {
if (pool.getName().equals(name)) {
return pool;
}
}
throw new RuntimeException("Expected to find a memory pool with name " + name);
}
public static void foo() {
MemoryPoolMXBean a = getMemoryPool("Compressed Class Space");
MemoryPoolMXBean a = getMemoryPool("Non Class Space");
}
If we remove `CompressedClassSpace`, we can only `getMemoryPool("Metaspace")`. Although metaspace is not baked in the specification, IMHO it's easier for developers to understand what is `metaspace` compared to the concepts of `Non Class Space` and `Compressed Class Space`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8831
More information about the hotspot-runtime-dev
mailing list