File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Garbage collection on Connection Factory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Garbage collection on Connection Factory" Watch "Garbage collection on Connection Factory" New topic

Garbage collection on Connection Factory

Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Not necessary. In my opinion. But why would you need that?

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Frank Zheng
Ranch Hand

Joined: Jun 12, 2001
Posts: 76
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,

Sun Certified Java Programmer
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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.
Michael Morris
I agree. Here's the link:
subject: Garbage collection on Connection Factory
It's not a secret anymore!