Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java : how to check current Perm / PermGen Size?

Yesterday when I was running the WebLogic Application Server 11g installer, I encountered a OutOfMemory error, so I Googled for the answer:

java -Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m -jar wls1032_generic.jar

Everything worked :)

However, when I think twice about the solution, I might have made a mistake: How could I know the current settings of those? I certainly need to check their values before overriding them, right?

Any thoughts?

Related link: People in another thread on SO suggested trial and error approach, which is not ideal.

Many thanks in advance.

like image 411
Michael Mao Avatar asked Sep 16 '10 00:09

Michael Mao


People also ask

What is perm size in Java?

It's maximum value of Permanent Space that JVM can allot up to. Examples of using -XX:PermSize VM (JVM) option in java > Example1 of using -XX:PermSize VM (JVM) option in java > java -XX:PermSize=512m MyJavaProgram. It will set initial value of Permanent Space as 512 megabytes to JVM.

How do I change the PermGen size?

To increase the PermGen memory change the value of the MaxPermSize variable, otherwise change the value of the Xmx variable.

What is the Java 8 update of Perm Gen?

Due to the above problems, PermGen has been completely removed in Java 8. In the place of PermGen, a new feature called Meta Space has been introduced. MetaSpace grows automatically by default. Here, the garbage collection is automatically triggered when the class metadata usage reaches its maximum metaspace size.


2 Answers

You can check the values of any JVM flags of a running JVM by using the jinfo.exe utility.

%JAVA_HOME%\bin\jinfo.exe -flag <flagName> <pid>

so to check the value of -XX:PermSize JVM option you can run

%JAVA_HOME%\bin\jinfo.exe -flag PermSize <pid>

like image 90
Strelok Avatar answered Oct 05 '22 03:10

Strelok


You can use jmap at here, it's JVM Heap Dump Tool.

for example:

jmap -heap 5900

It will print:

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 989855744 (944.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 85983232 (82.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 242352128 (231.125MB)
   used     = 9196056 (8.770042419433594MB)
   free     = 233156072 (222.3549575805664MB)
   3.79450185805672% used
From Space:
   capacity = 41877504 (39.9375MB)
   used     = 0 (0.0MB)
   free     = 41877504 (39.9375MB)
   0.0% used
To Space:
   capacity = 42663936 (40.6875MB)
   used     = 0 (0.0MB)
   free     = 42663936 (40.6875MB)
   0.0% used
PS Old Generation
   capacity = 80609280 (76.875MB)
   used     = 34187936 (32.604156494140625MB)
   free     = 46421344 (44.270843505859375MB)
   42.41191088668699% used
PS Perm Generation
   capacity = 85393408 (81.4375MB)
   used     = 63472624 (60.53221130371094MB)
   free     = 21920784 (20.905288696289062MB)
   74.32965317416539% used

It gets memory information (including PermGen).5900 is the process id of Java.

like image 22
Alan Avatar answered Oct 05 '22 04:10

Alan