Thread GC problem

breed at almaden.ibm.com breed at almaden.ibm.com
Fri Aug 21 17:50:51 PDT 1998


Are the threads being garbage collected properly?  I can't really see where
the dead threads are getting garbage collected,  The finalizer doesn't seem
to be called on a dead thread, and the # of thread contexts keep
increasing.  My observations are based on running the following program:

import java.util.Random;
class gctest extends Thread {
  static Random r = new Random();
  byte b[];
  public void run() {
    b = new byte[r.nextInt() & 0xff];
    System.out.println( "all done" );
  }
  protected void finalize() { System.out.println( "Collecting " + this ); }

  public static void main( String a[] ) {
    for( int i = 0; i < Integer.parseInt( a[0] ); i++ ) {
      new gctest().start();
      //      System.err.println( b.length );
      try {
        Thread.sleep( 1000 );
        System.gc();
      } catch( Exception e ) {}
    }
  }
}

with the following command line:

java -verbosemem -mx 6500000 gctest 10000




More information about the kaffe mailing list