garbage collection

Davor Cubranic cubranic at cs.ubc.ca
Wed May 20 03:15:03 PDT 1998


Hello,

Out of curiosity, I've played a bit with tracing the garbage collector to see 
how the objects get freed when they are no longer needed. Admittedly, my 
program was fairly simple, but I was unable to get any of objects that were 
temporarily created to be freed.

This is what the program looked like:

class intToString
{
public String s;
    
public intToString(int inarg) {
    s = String.valueOf(inarg);
}

}

class TestGC {
public static void main (String args[]) {
    int i;
    intToString is;
    for (i = 0; i < 1000; i++) {
	is = new intToString(i);
	System.out.println(is.s);
    }
}
}
    
Ten intToString's get created, but, as I said, not freed. Could somebody send 
me a sample program that was used to test GC? (Or something that you think 
should kick it in action.)

Davor



More information about the kaffe mailing list