How to determine the size of PermGen within a Java application (i.e., programmatically)?

s106mo picture s106mo · Nov 1, 2010 · Viewed 10.5k times · Source
  1. Is there any way to measure the currently used size of permanent generation (PermGen) within my Java application? I cannot use external profiling tools such as VisualVM.

  2. Even better would be an estimation of the memory consumption of a Java class in the PermGen. Is it nearly proportional to the size of the bytecode file?

Answer

Aravind Yarram picture Aravind Yarram · Nov 1, 2010

You could use MemoryMXBean that comes with JDK. But I don't think there is a way to query on the permgen usage from within a running application. Docs about MemoryMXBean.