Search code examples
javagarbage-collectionjvmjstat

High Perm Generation and Low Old Generation


We have actually increase the memory for the jvm to 256M and now the old generation looks very small but the Perm Generation is quite high nearly 80%. Sample data capture via jstat is as below. What does a high perm generation indicate here?

Timestamp        S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT   
       173656.0 1152.0 1216.0 864.0   0.0   84928.0  26778.0   174784.0   11967.6   21248.0 17057.8     62    3.653   0      0.000    3.653
       173671.0 1152.0 1216.0 864.0   0.0   84928.0  27843.4   174784.0   11967.6   21248.0 17057.8     62    3.653   0      0.000    3.653
       173686.1 1152.0 1216.0 864.0   0.0   84928.0  27843.4   174784.0   11967.6   21248.0 17057.8     62    3.653   0      0.000    3.653
       173701.1 1152.0 1216.0 864.0   0.0   84928.0  27843.4   174784.0   11967.6   21248.0 17057.8     62    3.653   0      0.000    3.653
       173716.0 1152.0 1216.0 864.0   0.0   84928.0  27843.4   174784.0   11967.6   21248.0 17057.8     62    3.653   0      0.000    3.653

Samples before restart

Timestamp        S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT   
       261578.8   0.00  16.89  68.70   8.89  80.74     45    2.551     0    0.000    2.551
       261593.8   0.00  16.89  70.97   8.89  80.74     45    2.551     0    0.000    2.551
       261608.8   0.00  16.89  72.49   8.89  80.74     45    2.551     0    0.000    2.551
       261623.8   0.00  16.89  75.00   8.89  80.74     45    2.551     0    0.000    2.551
       261638.8   0.00  16.89  77.76   8.89  80.74     45    2.551     0    0.000    2.551
       261653.8   0.00  16.89  80.77   8.89  80.74     45    2.551     0    0.000    2.551
       261668.8   0.00  16.89  83.03   8.89  80.74     45    2.551     0    0.000    2.551
       261683.8   0.00  16.89  85.29   8.89  80.74     45    2.551     0    0.000    2.551
       261698.8   0.00  16.89  87.57   8.89  80.74     45    2.551     0    0.000    2.551
       261713.8   0.00  16.89  90.57   8.89  80.74     45    2.551     0    0.000    2.551
       261728.8   0.00  16.89  93.35   8.89  80.74     45    2.551     0    0.000    2.551
       261743.8   0.00  16.89  95.61   8.89  80.74     45    2.551     0    0.000    2.551
       261758.8   0.00  16.89  98.61   8.89  80.74     45    2.551     0    0.000    2.551
       261773.8  20.83   0.00   1.36   8.95  80.74     46    2.685     0    0.000    2.685
       261788.8  20.83   0.00   4.66   8.95  80.74     46    2.685     0    0.000    2.685
       261803.8  20.83   0.00   6.88   8.95  80.74     46    2.685     0    0.000    2.685
       261818.8  20.83   0.00   9.67   8.95  80.74     46    2.685     0    0.000    2.685
       261833.8  20.83   0.00  10.78   8.95  80.74     46    2.685     0    0.000    2.685
       261848.8  20.83   0.00  13.56   8.95  80.74     46    2.685     0    0.000    2.685
       261863.9  20.83   0.00  15.78   8.95  80.74     46    2.685     0    0.000    2.685
       261878.8  20.83   0.00  19.32   8.95  80.74     46    2.685     0    0.000    2.685
       261893.8  20.83   0.00  21.55   8.95  80.74     46    2.685     0    0.000    2.685
       261908.8  20.83   0.00  24.33   8.95  80.74     46    2.685     0    0.000    2.685
       261923.8  20.83   0.00  27.11   8.95  80.74     46    2.685     0    0.000    2.685
       261938.8  20.83   0.00  29.84   8.95  80.74     46    2.685     0    0.000    2.685
       261953.8  20.83   0.00  32.06   8.95  80.74     46    2.685     0    0.000    2.685
       261968.8  20.83   0.00  34.85   8.95  80.74     46    2.685     0    0.000    2.685
       261983.8  20.83   0.00  38.89   8.95  80.74     46    2.685     0    0.000    2.685

Samples afte restart

Timestamp        S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT   
          135.8   0.00   0.00  72.71   0.00  70.88      0    0.000     0    0.000    0.000
          150.8   0.00   0.00  76.71   0.00  70.91      0    0.000     0    0.000    0.000
          165.8   0.00   0.00  78.71   0.00  70.94      0    0.000     0    0.000    0.000
          180.7   0.00   0.00  82.71   0.00  72.79      0    0.000     0    0.000    0.000
          195.8   0.00   0.00  84.71   0.00  72.81      0    0.000     0    0.000    0.000
          210.8   0.00   0.00  88.71   0.00  72.90      0    0.000     0    0.000    0.000
          225.8   0.00   0.00  92.71   0.00  72.93      0    0.000     0    0.000    0.000
          240.8   0.00   0.00  94.71   0.00  72.95      0    0.000     0    0.000    0.000
          255.8   0.00   0.00 100.00   0.00  73.02      0    0.000     0    0.000    0.000
          270.8   0.00  78.72   6.68   0.00  73.49      1    0.286     0    0.000    0.286
          285.8   0.00  78.72  10.66   0.00  73.50      1    0.286     0    0.000    0.286
          300.8   0.00  78.72  14.32   0.00  73.54      1    0.286     0    0.000    0.286
          315.8   0.00  78.72  18.89   0.00  73.57      1    0.286     0    0.000    0.286
          330.8   0.00  78.72  24.85   0.00  73.57      1    0.286     0    0.000    0.286
          345.8   0.00  78.72  30.18   0.00  76.84      1    0.286     0    0.000    0.286
          360.8   0.00  78.72  32.82   0.00  76.86      1    0.286     0    0.000    0.286
          375.8   0.00  78.72  36.04   0.00  76.87      1    0.286     0    0.000    0.286
          390.8   0.00  78.72  40.00   0.00  76.89      1    0.286     0    0.000    0.286
          405.8   0.00  78.72  43.96   0.00  76.91      1    0.286     0    0.000    0.286
          420.8   0.00  78.72  46.61   0.00  76.92      1    0.286     0    0.000    0.286
          435.8   0.00  78.72  47.63   0.00  76.92      1    0.286     0    0.000    0.286
          450.8   0.00  78.72  47.63   0.00  76.92      1    0.286     0    0.000    0.286
          465.8   0.00  78.72  47.63   0.00  76.92      1    0.286     0    0.000    0.286
          480.8   0.00  78.72  47.63   0.00  76.92      1    0.286     0    0.000    0.286
          495.8   0.00  78.72  48.54   0.00  76.93      1    0.286     0    0.000    0.286
          510.8   0.00  78.72  48.54   0.00  76.93      1    0.286     0    0.000    0.286
          525.8   0.00  78.72  48.54   0.00  76.93      1    0.286     0    0.000    0.286
          540.8   0.00  78.72  49.11   0.00  76.93      1    0.286     0    0.000    0.286
          555.8   0.00  78.72  49.11   0.00  76.93      1    0.286     0    0.000    0.286
          570.8   0.00  78.72  49.11   0.00  76.93      1    0.286     0    0.000    0.286
          585.8   0.00  78.72  49.11   0.00  76.93      1    0.286     0    0.000    0.286
          600.8   0.00  78.72  49.11   0.00  76.93      1    0.286     0    0.000    0.286
          615.8   0.00  78.72  49.11   0.00  76.93      1    0.286     0    0.000    0.286
          630.8   0.00  78.72  49.11   0.00  76.93      1    0.286     0    0.000    0.286
          645.8   0.00  78.72  49.98   0.00  76.93      1    0.286     0    0.000    0.286
          660.8   0.00  78.72  49.98   0.00  76.93      1    0.286     0    0.000    0.286
          675.8   0.00  78.72  49.98   0.00  76.93      1    0.286     0    0.000    0.286
          690.8   0.00  78.72  49.98   0.00  76.93      1    0.286     0    0.000    0.286
          705.8   0.00  78.72  49.98   0.00  76.93      1    0.286     0    0.000    0.286
          720.8   0.00  78.72  50.55   0.00  76.93      1    0.286     0    0.000    0.286
          735.8   0.00  78.72  51.12   0.00  76.93      1    0.286     0    0.000    0.286
          750.8   0.00  78.72  51.12   0.00  76.93      1    0.286     0    0.000    0.286
          765.8   0.00  78.72  51.12   0.00  76.93      1    0.286     0    0.000    0.286
          780.8   0.00  78.72  51.12   0.00  76.93      1    0.286     0    0.000    0.286
          795.8   0.00  78.72  51.12   0.00  76.93      1    0.286     0    0.000    0.286
          810.8   0.00  78.72  51.12   0.00  76.93      1    0.286     0    0.000    0.286
          825.8   0.00  78.72  51.69   0.00  76.93      1    0.286     0    0.000    0.286
          840.8   0.00  78.72  51.69   0.00  76.93      1    0.286     0    0.000    0.286
          855.8   0.00  78.72  51.69   0.00  76.93      1    0.286     0    0.000    0.286
          870.8   0.00  78.72  51.69   0.00  76.93      1    0.286     0    0.000    0.286
          885.8   0.00  78.72  52.26   0.00  76.95      1    0.286     0    0.000    0.286
          900.8   0.00  78.72  52.26   0.00  76.95      1    0.286     0    0.000    0.286
          915.8   0.00  78.72  53.12   0.00  76.95      1    0.286     0    0.000    0.286
          930.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
          945.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
          960.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
          975.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
          990.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
         1005.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
         1020.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
         1035.8   0.00  78.72  53.69   0.00  76.95      1    0.286     0    0.000    0.286
         1050.8   0.00  78.72  54.27   0.00  76.95      1    0.286     0    0.000    0.286
         1065.8   0.00  78.72  54.27   0.00  76.95      1    0.286     0    0.000    0.286
         1080.8   0.00  78.72  54.27   0.00  76.95      1    0.286     0    0.000    0.286
         1095.8   0.00  78.72  54.27   0.00  76.95      1    0.286     0    0.000    0.286
         1110.8   0.00  78.72  55.12   0.00  76.97      1    0.286     0    0.000    0.286
         1125.8   0.00  78.72  55.46   0.00  76.97      1    0.286     0    0.000    0.286
         1140.8   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1155.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1170.8   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1185.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1200.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1215.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1230.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1245.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1260.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1275.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1290.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1305.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286
         1320.9   0.00  78.72  56.03   0.00  76.97      1    0.286     0    0.000    0.286

Classes used are

import java.io.*;
import java.net.*;
import java.util.*;
import java.util.Date;
import java.text.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.*;
import java.util.concurrent.LinkedBlockingQueue;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import com.jolbox.bonecp.BoneCP;
import com.jolbox.bonecp.BoneCPConfig;

Skeleton of the codes.

public static void main(String[] args) {   

      new sServer7888();

   }
sServer7888() {


    try{
    final ServerSocket serverSocketConn = new ServerSocket(7888);               
    while (true){
    try{
       Socket socketConn1 = serverSocketConn.accept();
          new Thread(new ConnectionHandler(socketConn1)).start();                       
    }
    catch(Exception e){
        e.printStackTrace(System.out);
    }
       }
    } 
    catch (Exception e)     {
         e.printStackTrace(System.out);
    }

}


class ConnectionHandler implements Runnable {

  private Socket receivedSocketConn1;
    ConnectionHandler(Socket receivedSocketConn1) {
      this.receivedSocketConn1=receivedSocketConn1;
    }

    public void run() {

      while ((nextChar=readIn1.read()) != -1) {

         completeMessage += (char) nextChar;     
         if (nextChar == '*')
         {

          //calling of various function depends on the input data
          completeMessage="";

         }
       }   
      }
   }
}

Solution

  • You app is just running - there is nothing special here.

    • In this 60 seconds no GC was run (neither small nor full GC)
    • It seems that a minimum number of objects are generated, there is a slight increase in the Eden space

    If the application was running before (meaning that all classes were loaded) you don't have to worry about the PermGen space.

    Otherwise it would be nice if you could show all your memory-related system parameters.

    Concerning the 2nd and 3rd samples:

    The 2nd sample (before restart) shows that the application has never run a FullGC. It means, that the space for objects is enough. Similarly technically no change in PermGen space, it means that the application already loaded all required classes, no new classloading happens.

    The third example (after restart) shows that the application is slowly loading all necessary classes, at the end technically no new classes are loaded for minutes. It does not mean, that it will never happen, it only means that the app after 20 minutes already loaded the required classes. So, no new big increase is expected.

    Although it may happen that some hidden part of the application becomes active, and you will load a number of classes, imagine that you have 5 times more space than you actually allocated. Also, it is a finite process, after a class was loaded, it will not be loaded again.