Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5037007

Unexpected Full GC occurs at 54% of old generation capacity

    XMLWordPrintable

Details

    • gc
    • b01
    • sparc
    • solaris_8

    Description

      The testcase below can demonstrate that Full GC kicks in when old generation is only 54% of its capacity. The heap size should be set to 3GB

      CoreGenerator.java
      import java.util.*;

      public class CoreGenerator implements Runnable
      {
         static Random generator = new Random();
         private String genString( int length )
         {
            final byte space = 32;
            final int range = 128 - 32;
               char newMessage[] = new char[ length ];
               for ( int j = 0; j < length; j++ )
               {
                  newMessage[ j ] = (char)( space + (byte) generator.nextInt( range ) );
               }
               return new String( newMessage );
         }
         public void run()
         {
            HashMap hm = new HashMap( 1024 );
            final int maxLength = 4 * 1024 * 1024;
            for ( int i = 1; i < 2 * 1024 * 1024; i++ )
            {
               hm.put( new Integer( i ), genString( generator.nextInt( maxLength ) ) );
               if (0 == ( i % 20 ) )
               {
                  hm.put( new Integer( generator.nextInt( i ) ), genString( generator.nextInt( maxLength ) ) );
               }
            }
         }
         public static void main( String args[] )
         {
            for ( int i = 0; i < 20; i++ )
            {
               new Thread( new CoreGenerator() ).start();
            }
         }
      }

      Run this test program with foillowing options:

      java -DORB.OrbName=CoreTest -Xms3g -Xmx3g -XX:NewSize=300m -XX:MaxNewSize=300m -XX:SurvivorRatio=4 -XX:+PrintCompilation -XX:+UseParallelGC -XX:ParallelGCThreads=24 -XX:MaxPermSize=256MB -XX:PermSize=256m -XX:-UseAdaptiveSizePolicy -XX:+DisableExplicitGC -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCTimeStamps -Xnoclassgc -verbose:gc CoreGenerator

      Note that ParalleGC is used for young gen.

      Attachments

        Activity

          People

            jcoomes John Coomes (Inactive)
            rramchansunw Rajesh Ramchandani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: