MS Access still in memory

S

Stuart

I am running in a single user environment. Under certain conditions (I can't
pinpoint exactly) when I exit Access, the .LDB file remains. I brought up
the Task Manager and discovered that Access is still running! 10 minutes
later and it is still running, although there is no other evidence of it.
What would cause this?

Thanks, Stuart
 
6

'69 Camaro

Hi, Stuart.
when I exit Access, the .LDB file remains. I brought up
the Task Manager and discovered that Access is still running!

This is often caused by creating a Recordset variable in code and then
letting it go out of scope without releasing resources. Since Access is
still holding the Recordset in memory, it's still running after you quit
Access. It's impossible to release the memory allocated in memory for this
Recordset after it goes out of scope, so the Task Manager must be used to
kill the process.

Search through your code to see whether there are any open Recordsets that
are left open when procedures exit, particularly in error handlers where many
programmers forget to close the Recordset and then set the variable to
Nothing.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.
 
S

Stuart

Thanks very much for the reply. I have looked through the code, and I am not
finding what you describe. There are a lot of

Dim rs As Object
Set rs = Me.RecordsetClone

These rs's are not closed. When the Dim statement is

Dim rs as Recordset

there is always a close statement, with no way to get around it. Should I
be putting close statements on the "rs-as-object"s? (the wizard that created
them didn't).

Thanks, Stuart
 
6

'69 Camaro

Hi, Stuart.
Dim rs As Object
Set rs = Me.RecordsetClone

These rs's are not closed.

You found the smoking gun. (There may be more, so don't get too excited.)
Should I
be putting close statements on the "rs-as-object"s? (the wizard that created
them didn't).

The Wizard didn't because the Wizard code was written for any possible mixed
environment of DAO and ADO libraries. The generic Object is "safe" in these
environments. I haven't seen your Wizard code that follows, but I would
guess that you could change:

Dim rs As Object

To:

Dim rs As DAO.Recordset

and set a Reference to the DAO 3.6 Object Library if it isn't already set.
Save the code and compile it.

Depending upon the code that follows, you may need to use ADODB.Recordset
instead. In that case, set a Reference to the ADO 2.x Object Library if it
isn't already set, save and compile.

Then you can add code to these procedures so that these Recordsets are
closed when they are no longer needed, then set the variable to Nothing
before the procedure ends. For example:

rs.Close
Set rs = Nothing
Exit Sub

ErrorHandler:
' Rest of code.
End Sub


HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.
 
Top