This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Calling the garbage collector.


Hi,

I have a simple java program to test the garbage collection. It has
the two java files shown below.

TestClass.java

public class TestClass {
        protected void finalize() throws Throwable {
                System.out.println("Java TestClass finalizer called.");
        }
}


HelloWorld.java

import TestClass;

class HelloWorld
{
        public static void main(String args[]) {
                System.out.println("HelloWorld\n");

                TestClass a =  new TestClass();
                a = null;
                System.gc();
        }
}


When I compile this using javac to a class file and run the bytecode
using the 'java' interpreter, the finalize funtion for TestClass.java
is called.
When I compile the same set of files using gcj to machine code, the
finalizer is not called. Can any one tell me why this happens and what
I will have to do to get the finalizer called when object is no longer
used.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]