public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Calling the garbage collector.
@ 2009-07-27 15:37 Chris Gray
  2009-07-27 16:16 ` BGB
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Gray @ 2009-07-27 15:37 UTC (permalink / raw)
  To: cr88192; +Cc: aph, abhi00, java

-

> hmm...
>
> maybe Java needs 'delete'?...

As in "maybe the pope needs a wife"? :-)

Automatic garbage collection means you don't know when garbage will be
collected, it could even be "after the VM exits", i.e. never. Running all
finalizers when the VM exits has been tried, and it was a disaster.

http://www.velocityreviews.com/forums/t145751-finalize-not-guaranteed-to-be-called-ever.html
http://www.hpl.hp.com/personal/Hans_Boehm/popl03/slides.pdf

etc..

PS I'm happy to report that the Mika VM also does not run your finalizer. :-)


Chris Gray      /k/ Embedded Java Solutions

_________________________________________
Scarlet Mobile, free subscription in combination with your Scarlet One or ADSL, visit http://www.scarlet.be/fr/mobile3g


^ permalink raw reply	[flat|nested] 5+ messages in thread
* Calling the garbage collector.
@ 2009-07-27  9:41 abhishek desai
  2009-07-27 10:07 ` Andrew Haley
  0 siblings, 1 reply; 5+ messages in thread
From: abhishek desai @ 2009-07-27  9:41 UTC (permalink / raw)
  To: java

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-27 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-27 15:37 Calling the garbage collector Chris Gray
2009-07-27 16:16 ` BGB
  -- strict thread matches above, loose matches on Subject: below --
2009-07-27  9:41 abhishek desai
2009-07-27 10:07 ` Andrew Haley
2009-07-27 14:43   ` BGB

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).