November 27, 2009, Newsletter Issue #79: Close those objects!

Tip of the Week

When you instantiate an obbect, such as a connection, recordset, filesystemobject, etc., remember to .close them, and to also set them to "nothing". Each time an object is created, memory is used up. Yes, when you exit a function the object instantiated within them go out of scope and supposedly are close, but it's a good programming practice to close and free up anyway.
For example:
dim rs
set rs = getUsersRS()
if not rs.eof then
do while not rs.eof

'do something here
rs.movenext
loop
end if
rs.close
if not rs is nothing then set rs = nothing

this effectively kills off the recordset object rs.

About LifeTips

Now one of the top on-line publishers in the world, LifeTips offers tips to millions of monthly visitors. Our mission mission is to make your life smarter, better, faster and wiser. Expert writers earn dough for what they know. And exclusive sponsors in each niche topic help us make-it-all happen.

Not finding the advice and tips you need on this Web Development Tip Site? Request a Tip Now!


Guru Spotlight
Jennifer Mathes, Ph.D.