This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a question regarding garbage collection. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a question regarding garbage collection." Watch "a question regarding garbage collection." New topic
Author

a question regarding garbage collection.

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
what does the sentence below trying to say?
could somebody please help? Thank you

"In relying on the automatic garbage collector, a Java program also forfeits any significant influence on the garbage collection of its objects."
Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
Hi,

"In relying on the automatic garbage collector, a Java program also forfeits any significant influence on the garbage collection of its objects."


Java's Garbage Collector (GC) is a proces that runs on itself
and comes into action without being asked for, additionally
even if you ask for it with it is only a hint.

Given the above behaviour, if you program in such a way that
you rely on the GC to clean up your memory, you are not in
control what might happen and when it happens.

I guess the author wants to say you'd better take care of
cleaning up allocated memory yourself, for example by
properly closing file objects, database connections,
unused references, etc.

I hope I was clearer

Cheers,

Gian Franco


"Eppur si muove!"
Tom Tolman
Ranch Hand

Joined: Sep 02, 2004
Posts: 83
"In relying on the automatic garbage collector, a Java program also forfeits any significant influence on the garbage collection of its objects."

My guess is the author is pointing out what he feels is a weakness of the Java language- lack of guaranteed control of memory management. My guess is that he is trying to say "please change the language specification for System.gc so that it guarantees any free memory is cleaned up"
Louie van Bommel
Ranch Hand

Joined: Aug 17, 2004
Posts: 76
Originally posted by sura watthana:
"In relying on the automatic garbage collector, a Java program also forfeits any significant influence on the garbage collection of its objects."


Translation (to English hehe)
Because Java programs must conform to the language specifications when it comes to garbage collection of its objects, the program cannot explicitly guarantee behaviour of such things as when the objects are garbage collected, nor can the program explicitly mark an object ready for garbage collection. Therefore the program doesn't have much influence on garbage collection behaviours for its objects.

Part of the confusion of this sentence is in the word "forfeits". It's inappropriate, because a program has no choice: it MUST rely on the automatic garbage collection, therefore there is no forfeiting involved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a question regarding garbage collection.