• Post Reply Bookmark Topic Watch Topic
  • New Topic

item eligible for garbage collection  RSS feed

 
Ranch Hand
Posts: 205
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have the following method call:

Would the Class1 object be eligible for garbage collection after line 7 or would you have to wait until the method call was finished (after line 2) to consider the object out of scope and thus eligible for garbage collection?
 
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a local variable which (in this case) effectively ceases to exist when the execution of the body of the method is complete.

So I would say it's eligible for GC after line 7 as this is the last statement of m1's body.
 
Kendall Ponder
Ranch Hand
Posts: 205
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is what i thought but I wanted to check. Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!