Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

correct way to clean memory??? 1

Status
Not open for further replies.

jeffmoore

Programmer
Joined
Aug 29, 2003
Messages
301
Location
US
What is the correct way to make sure all the stuff that is done in a module or procedure is closed and the memory freed?

the ones I know about are...

rs.Close
Set db = Nothing

should I have a doevents after these statments to allow access to do its housekeeping?
TIA
Jeff
 
Hi Jeff,

The DoEvents directive doesn't help Access manage memory, but rather allows Access to refresh displays.

The examples you provided pretty much cover the scope of good housekeeping in code. Just remember to destroy objects (object = Nothing) and close files or connections when you no longer need them.

Another tip in Access memory management would be to make sure you do not have too many controls on a single form. The usage of subforms can make a big difference in resource load on the client computer.

Hope this helps.

- Glen

Know thy data.
 
Then I'm in trouble!!
I have a report that is a wopper. close to 200 controls that have data. Since the data is displayed with subtle differences that is dependent of the data it's self I had to rule out a sub form or table type views.
thanks for the tips.
Jeff
 
The DoEvents can help Access manage memory.

What DoEvents does is hand control back to the system to process outstanding messages. Some of those messages have to do with refreshing displays that is true, but other messages might be to flush file buffers from a Close event, or handle a Form_Close event which contains cleanup code.

The answer to your question is to Close all objects that require opening, and to set all objects to Nothing when you're done with them.

Why do you think you're in trouble?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Good catch! I stand corrected.

As CajunCenturion suggested, the DoEvents passes control back to the OS to allow any queued system events to fire. This probably would not be a bad standard practice, especially in long running batch scenerios where you would want to clean up between a multi-step (or multi-file) process.

A star to CajunCenturion for the good information. :~)-

- Glen

Know thy data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top