Re: Calling the garbage collector.
"BGB" <[email protected]>
| Newsgroups | gmane.comp.gcc.java.devel |
|---|---|
| Message-ID | <[email protected]> |
----- Original Message ----- From: "Chris Gray" <[email protected]> To: "cr88192" <[email protected]> Cc: "aph" <[email protected]>; "abhi00" <[email protected]>; "java" <[email protected]> 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...