[AccessD] How to tell how much resources have been used

Bill Benson bensonforums at gmail.com
Sun Jun 7 06:58:20 CDT 2015


Recently I had some problems with Access consuming too many "resources"
when trying to output some reports to disk consecutively, using VBA. I
wrote a routine that interrupted the process at various stages and
suggested the user quit Access and restart the database, then on startup,
looks for where things left off and continues. Even though this mitigates
risk, it is still possible for Access to run out of resources along the way
at any particular stage it happens to open up and carry on from. I creating
an alternative that automates a second instance of Access to run the
reports. However this will add a significant amount of time to the running
process. I would like therefore to know if there is a way to test how much
RAM is being used by a process in order to permitting the 2nd instance to
crank out reports up until an optimal stopping point.

I found some code here https://goo.gl/g8ZkTT that purports to find the
amount of available memory (plus a whole lot of other info) however (1) the
amount is always being reported as a negative number (e.g.,

      ?MemoryAvailable
      -475230208

Also, I am wondering if I would have to enhance the API definitions in
order to accommodate Windows 8.1, which my Firm is movint towards.

Anyone have experience with this API call and how to cover the bases I am
conderned with?

Option Compare Database
Option Explicit
Type MEMORYSTATUS
    dwLength As Long
    dwMemoryLoad As Long
    dwTotalPhys As Long
    dwAvailPhys As Long
    dwTotalPageFile As Long
    dwAvailPageFile As Long
    dwTotalVirtual As Long
    dwAvailVirtual As Long
End Type
Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As _
            MEMORYSTATUS)

Function MemoryAvailable()
Dim msg As String         ' Status information.
Dim NewLine As String     ' New-line.
Dim ret As Integer        ' OS Information
Dim ver_major As Integer  ' OS Version
Dim ver_minor As Integer  ' Minor Os Version
Dim Build As Long         ' OS Build
Dim memsts As MEMORYSTATUS
GlobalMemoryStatus memsts
MemoryAvailable = memsts.dwAvailPhys
'MemoryAvailable = memsts.dwLength
'MemoryAvailable = memsts.dwMemoryLoad
'MemoryAvailable = memsts.dwTotalPhys
'MemoryAvailable = memsts.dwAvailPhys
'MemoryAvailable = memsts.dwTotalPageFile
'MemoryAvailable = memsts.dwAvailPageFile
'MemoryAvailable = memsts.dwTotalVirtual
'MemoryAvailable = memsts.dwAvailVirtual
End Function


More information about the AccessD mailing list