This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection on Connection Factory

 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I've noticed in some example code from various sources, that before returning a connection object to a remote client, they make a call to System.gc(). Is this necessary or desireable?
Thanks for your opinions
Michael Morris
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not necessary. In my opinion. But why would you need that?
Mark
 
Frank Zheng
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You may want to set some not used variables to null to help garbage collection. But, you need not call System.gc()and you will never know when the garbage being collected.
Hope this helps,
Frank
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
I don't see any point in it either. I've just seen several code examples in books I've read that request gc in that situation. I just wanted to make sure there wasn't some rule of thumb that I was unaware of.
Thanks,
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic