Implementing the finalize method just for printing should be avoided. If you
implement it, there will be an instance of Finalizer class per every object
(if I remember it correctly). In http://java.sun.com/docs/books/performance/
it is said "The only thing that can be said for certain is that adding a
finalizer will extend the lifetime of an object". I can recommend that book
and the OptimizeIt software.

Pasi

-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of Karsten Fries
Sent: 17. heinakuuta 2001 10:18
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Memory handling


Oops,


> Also, to truly override finalize of the Java native classes,
> finalize must be declared protected, not private as I formerly stated or
> public as in Karsten's code.

thanks for the correction. Lazyness is always awkward.

> protected void finalize() throws Throwable {
>     // your code / print outs
>     // watch out not to cause an exception. it will not be reported,
> since the system will catch them silently
>     ....
>     // this is very important, never forget it. The super class could
> free memory of native code
>     super.finalize();
> }

One step further would be

protected void finalize() throws Throwable {

    try {

       // your code / print outs

    }
    catch ( Throwable e ) {

        // we are lucky having our own exception caught and we get feedback
        e.printStackTrace();

    }

   // this is very important, never forget it. The super class could free
memory of native code
   super.finalize();}

}

> Have a great day,

You too!

Cheers,
Karsten

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to