Calling the garbage collector.

BGB cr88192@hotmail.com
Mon Jul 27 16:16:00 GMT 2009


----- 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...


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /