[AccessD] 64-but ONLY front end ?

Ryan Wehler wrwehler at gmail.com
Mon Jan 23 19:05:12 CST 2017


Yes many record sets are used in various ways. I always close and set them to nothing as needed. I'll check out your code in the AM. 

Sent from my iPad

> On Jan 23, 2017, at 6:30 PM, Bill Benson <bensonforums at gmail.com> wrote:
> 
> 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
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



More information about the AccessD mailing list