Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

garbage collecting session objects

 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we store an object in a session variable and then store another object with the same name the first object is replaced. My question is, do we need to specifically get the original item out and set it to null or will it be eligible to be gc'd automatically as soon as it is replaced?
Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you replace the object, the session no longer has a reference. As long as your program does not have a reference, nobody has a reference and the object will be GCed.
Bill
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's kind of what I thought but wasn't sure.
Thanks Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic