File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes One quick question in the Garbage collection? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "One quick question in the Garbage collection?" Watch "One quick question in the Garbage collection?" New topic
Author

One quick question in the Garbage collection?

Shanmugam nagaraj
Ranch Hand

Joined: May 07, 2007
Posts: 76
Hi,
What all are the algorithm we are using in the garbage collection? what is the purpose of each algorithm? can you please explain me for my hard question which is simple to you?

Thanks

Shanmugam


Thanks <br />Shanmugam N
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
I'm not sure what you mean.

A Java programmer doesn't perform garbage collection.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The JVM does garbage collection for us. The algorithms are wonderfully complex and varied. It seems every new release of the JVM has improved gc. Googling on "Sun garbage collection algorithm" got a few hits like THIS. Note it is specific to one particular dot release of the JVM.

This is a fascinating area, but one we really should stay away from in coding. Don't try to optimize your code for some particular gc version, or try to invoke the gc yourself to improve performance. I trust that it is far smarter than I am, and it is likely to change in ways that will make my optimization today the worst possible choice tomorrow. So read it, be impressed, and try to forget.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Shanmugam nagaraj
Ranch Hand

Joined: May 07, 2007
Posts: 76
Hi,

Thanks for your timely response!
My sincere appologise for the inconvinience cause to you due to my communication gap and wasted your precious time.
I am very new to java and to javaranch also, now only I trying a job.

One interviewer asked me like:
What all are the algorithm using by jvm for garbage collection? What is the purpose of each?


For eg:
mark and sweep is one of the algorithm using by garbage collection. but he(inteviewer) say there is some more algorithm is available and each one is do one process while doing the garbage collection operation.


thanks
Shanmugam
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Follow up with the Google search I suggested, or craft your own search around mark-sweep and see what alternatives show up. This is neat stuff and in rare situations someone will really have to dig into all the tuning options on the JVM. I've always managed to make sure that wasn't me, so I can't rattle off the details.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
An interviewer asking that sort of question was either: -

(A) Not really expecting you to list all possible algorithms and describe them in detail, but instead just hoping to find out what you did know and whether you could talk intelligently on a non-trivial technical subject

... or ...

(B) A fool who didn't realise what a tough question it was

I guess you'll have determined which it was, by how the rest of the interview went.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Shanmugam nagaraj
Ranch Hand

Joined: May 07, 2007
Posts: 76
Hi
Thanks for your explanation.
At last peter make me fool
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: One quick question in the Garbage collection?
 
Similar Threads
garbage collection
finalize()
Mark and Sweep
Garbage Collection Algorithm in Java 5
Marcus Green Mock #2 Q 4