Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Garbage collection  RSS feed

 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1. How can u force an object to be garbage collected?
A. Remove all refernces from the object
B. You can not force an object to be garbage collected.
there were 2 more option.
I thought A.
but correct ans is given B.
But I think if you remove all references then it will be elgible for garbage collection and will collected by garbage collection thread.
correct me if I am wrong.
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i think you gave the answer yourself!

But I think if you remove all references then it will be elgible for garbage collection and will collected by garbage collection thread

it will be elgible for gc.
you cant force it to be gc.
 
Shivaji Marathe
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravish :
I believe there have neem several discussions on this topic before. Please do a search before posting questions. It will save you and everyone else a lot of time.
You can make an object eligible for garbage collection, but you can not force garbage collection to take place.
HTH
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!