Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection

 
Whiz Kid
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
I am not able to follow the Concept of garbaghe collection and How to enforce it in a program.
Can anyone help me with this and any resources or links regardiong this will be of great help.
thaanks So much
Gowri
 
Binu K Idicula
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot enforce garbage collection. But you can request the system to do that by calling System.gc().
Garbage colector is a low priority thread running asynchronously to your program exacution threads.
It detects unreachable objects, mark them ,invoke it's finalize (if overridden ), and frees memory all in the background with no specific time bound.
You cannot specify the exact time of garbage collection.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good article on garbage collection:
Reference Objects and Garbage Collection
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic