[AccessD] 64-but ONLY front end ?
Bill Benson
bensonforums at gmail.com
Mon Jan 23 18:30:48 CST 2017
Are you building recordsets? I found a couple years ago I had to keep track
of memory as I was creating recordsets, looping through them, performing
certain routines, because Ac2013 was not releasing memory. Big time memory
leaks.
I stole this code from somewhere to get how much memory was being used and
would test this midroutine, sending a msgbox to the user to quit the
application if they exceeded 800MB.
Option Compare Database
Option Explicit
Type PROCESS_MEMORY_COUNTERS
cb As Long
PageFaultCount As Long
PeakWorkingSetSize As Long
WorkingSetSize As Long
QuotaPeakPagedPoolUsage As Long
QuotaPagedPoolUsage As Long
QuotaPeakNonPagedPoolUsage As Long
QuotaNonPagedPoolUsage As Long
PagefileUsage As Long
PeakPagefileUsage As Long
End Type
Private Const PROCESS_QUERY_INFORMATION = 1024
Private Const PROCESS_VM_READ = 16
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function EnumProcessModules Lib "PSAPI.DLL" (ByVal hProcess
As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal
dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As
Long) As Long
Private Declare Function GetProcessMemoryInfo Lib "PSAPI.DLL" (ByVal
hProcess As Long, ppsmemCounters As PROCESS_MEMORY_COUNTERS, ByVal cb As
Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal Handle As
Long) As Long
Public Function Mem() As Long
Dim lngCBSize2 As Long
Dim lngModules(1 To 200) As Long
Dim lngReturn As Long
Dim lngHwndProcess As Long
Dim pmc As PROCESS_MEMORY_COUNTERS
Dim lRet As Long
Dim MemDelta As Long
Static MemUsed As Long
'Get a handle to the Process and Open
lngHwndProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or
PROCESS_VM_READ, 0, GetCurrentProcessId)
If lngHwndProcess <> 0 Then
'Get an array of the module handles for the specified process
lngReturn = EnumProcessModules(lngHwndProcess, lngModules(1), 200,
lngCBSize2)
'If the Module Array is retrieved, Get the ModuleFileName
If lngReturn <> 0 Then
'Get the Site of the Memory Structure
pmc.cb = LenB(pmc)
lRet = GetProcessMemoryInfo(lngHwndProcess, pmc, pmc.cb)
Mem = pmc.WorkingSetSize
End If
End If
'Close the handle to this process
lngReturn = CloseHandle(lngHwndProcess)
End Function
More information about the AccessD
mailing list