This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Calling the garbage collector.
- From: "BGB" <cr88192 at hotmail dot com>
- To: "Chris Gray" <mbx03025 at scarlet dot be>
- Cc: "aph" <aph at redhat dot com>, "abhi00" <abhi00 at gmail dot com>, "java" <java at gcc dot gnu dot org>
- Date: Mon, 27 Jul 2009 09:15:56 -0700
- Subject: Re: Calling the garbage collector.
- References: <KNG62F$A29CFBDE0DD882E74454F231B9825EE4@scarlet.be>
----- Original Message -----
From: "Chris Gray" <mbx03025@scarlet.be>
To: "cr88192" <cr88192@hotmail.com>
Cc: "aph" <aph@redhat.com>; "abhi00" <abhi00@gmail.com>; "java"
<java@gcc.gnu.org>
Sent: Monday, July 27, 2009 8:37 AM
Subject: Re: Calling the garbage collector.
-
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.
:-)
-->
I was partly joking, but yeah, GC is has some good points, and manual MM
some others.
personally, I prefer a hybrid strategy, where memory can be manually
freed/destroyed when it is known that it is not needed anymore, and left for
the GC when the usage pattern is "difficult to determine".
in my projects, I use a GC, but much of the time treat it much like good old
malloc/free...
so, in cases where it matters, one could essentially force the finalizer to
be run and the object to be freed...