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

String.intern() fails (internal memory allocation failure)

XMLWordPrintable

    • generic, x86
    • generic, windows_nt, windows_2000



      Name: md23716 Date: 08/28/2001

      String.intern() fails (internal memory allocation failure) when a large number of String objects are interned and can not be garbage collected by the JVM.

      In JDK 1.3.0 and 1.3.1 this is giving error message "Exception in thread main".

      There is also a SUNBUG:4035345 on the same problem. The bug was raised against 100000 string objects but the customer's testcase consists of 2000000 string objects. In the SUNBUG they mentioned as "fixed in 1.2.2" . But the customer's testcase fails in SUN JDK 1.2.2 also.

      Test case:

      public class Test
      {
        static private final int max = 2000000;
        static public void main( String[] args )
        {
          String[] holder = new String[ max ];
          for ( int i = 0; i < max; i++ ) {
                                           
            try {
       holder[ i ] = new String( Integer.toString( i ).intern() );
            } catch ( Throwable t ) {
                                     
       t.printStackTrace();
       System.err.println( t.toString() );
            }
          }
        }
      }
      ======================================================================

            chegar Chris Hegarty
            mdevereuorcl Michelle Devereux (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: