• Post Reply Bookmark Topic Watch Topic
  • New Topic

techniques used by garbage collector?  RSS feed

 
subho saha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some body tell me what are the techniques used by garbage collector to
keep track and free Object memories? Is "reference count"--- of how many variables point to an object a technique.Also what are the other ways?
 
soumya ravindranath
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google ? Trashtalk
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neat article, but copyright 2001. The language specs don't require any particular techniques or algorithms, and often a new JVM includes new GC routines. Over the years they have improved a great deal. I'm sure there is more to it today than in 2001. And much more to it than I even want to know.

A couple lessons:

Don't design your application based on some knowledge of the GC algorithms. If you say "The GC works this way, so I'll make my program work that way" you'll burn up your time and complicate your program in ways that might not even work in the next release.

Do pay attention to the info that is in the language spec. Avoid creating and destroying huge numbers of unnecessary objects. Watch variable scope and lifespan. Learn about Singleton, Flyweight, caching, pooling and weak references.

Play with the heap size on a really big program. With more heap GC runs less often, but may have a more noticable impact on the program as it runs. This effect has been reduced by background GC algorithms but might still be interesting.

Hope that helps! I thought it was going to be a one line answer when I started, but that never happens.
 
Richard Anderson
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Young man say once regarding the GC in Java:

NOTHING is guaranteed.

-Rich, SCJP 1.4
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!