| Other |
|---|
| tbdResolved |
|
Blocks :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
I played with various setting of MetaspaceSize/MaxMetaspaceSize and found that some combinations causes " java.lang.InternalError: Memory Pool not found" when I call pool.getUsage()
To reproduce this bug compile the following program:
----- MetaspaceSizeTest.java ---
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import java.util.List;
public class MetaspaceSizeTest {
public static void main(String args[]) {
MemoryPoolMXBean pool = getMemoryPool("Metaspace");
MemoryUsage mu = pool.getUsage();
System.out.println(mu);
}
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);
}
}
----------------
and run it as shown bellow:
# for x in 2m 3m ; do for y in 2m 3m 4m ; do echo "size: $x max: $y" ;java -XX:MetaspaceSize=$x -XX:MaxMetaspaceSize=$y MetaspaceSizeTest ; done ; done;
You will see:
size: 2m max: 2m
Exception in thread "main" java.lang.InternalError: Memory Pool not found
at sun.management.MemoryPoolImpl.getUsage0(Native Method)
at sun.management.MemoryPoolImpl.getUsage(MemoryPoolImpl.java:96)
at MetaspaceSizeTest.main(MetaspaceSizeTest.java:11)
size: 2m max: 3m
Exception in thread "main" java.lang.InternalError: Memory Pool not found
at sun.management.MemoryPoolImpl.getUsage0(Native Method)
at sun.management.MemoryPoolImpl.getUsage(MemoryPoolImpl.java:96)
at MetaspaceSizeTest.main(MetaspaceSizeTest.java:11)
size: 2m max: 4m
init = 2252800(2200K) used = 2069648(2021K) committed = 2265088(2212K) max = 4194304(4096K)
size: 3m max: 2m
Exception in thread "main" java.lang.InternalError: Memory Pool not found
at sun.management.MemoryPoolImpl.getUsage0(Native Method)
at sun.management.MemoryPoolImpl.getUsage(MemoryPoolImpl.java:96)
at MetaspaceSizeTest.main(MetaspaceSizeTest.java:11)
size: 3m max: 3m
Exception in thread "main" java.lang.InternalError: Memory Pool not found
at sun.management.MemoryPoolImpl.getUsage0(Native Method)
at sun.management.MemoryPoolImpl.getUsage(MemoryPoolImpl.java:96)
at MetaspaceSizeTest.main(MetaspaceSizeTest.java:11)
size: 3m max: 4m
init = 2252800(2200K) used = 2069648(2021K) committed = 2265088(2212K) max = 4194304(4096K)
===
# java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b107)
Java HotSpot(TM) Client VM (build 25.0-b49, mixed mode)
|