Reputation: 89613
Hi all I was wondering how do we get the size of the memory allocated per stack (e.g. -Xss512k),
and the size of the memory allocated to the PermGen space (e.g. XX:MaxPermSize=256m) ?
I've looked into
but the functions only return information about the heap space.
How do we query information about the stack space and the PermGen space?
Upvotes: 3
Views: 174
Reputation: 8513
Your journey starts at MemoryManagerMXBean where you can find all the memory pools; after that, ask MemoryPoolMXBean to find out details about a given pool.
The simplest way would be,
List<MemoryPoolMXBean> memoryPoolMXBeans =
ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean pool: memoryPoolMXBeans) {
out.println("pool: " + pool.getName());
out.println(" type: " + pool.getType());
out.println(" usage: " + pool.getUsage());
out.println();
}
Also, take a look at How to determine the maximum stack size limit? — they have a way to get the parameters passed to JVM.
Upvotes: 3