[AccessD] 64-but ONLY front end ?

Dan Waters df.waters at outlook.com
Mon Jan 23 20:09:41 CST 2017


Hi Bill,

I think what might be happening is that as your code loops through, there is a variable that represent the report in some way.  That variable is not being set to nothing before each new report is created, and that's where your memory is being consumed.

Try something like this:

Dim pdf

For each X in recordset

'Create report
Pdf = 'code'

'Export report
Pdf.Export

Set pdf = nothing

Next X

So, after you are finished processing the pdf, set it's variable to nothing.  That would hopefully prevent memory consumption from accumulating.  

Good Luck,
Dan

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bill Benson
Sent: Monday, January 23, 2017 19:44
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] 64-but ONLY front end ?

Well I spent a week on the issue and posed on this back in 2015 and I didn't get any help either. Maybe if I had the group here "peer review" my code someone would point put where I failed to take note of something.
But thing is I had a simple recordset. I was connected to SharePoint lists.

I would loop through each record, export a report (as pdf it so happens) and by about the 30th item I was getting out of memory. I wasn't creating any objects except the initial recordset.

So I concluded access sucks at memory management.

I just moved on.

Sorry if this is not much help and not a rigorous test.

>From my non-flammable Note 3,
Bill Benson

On Jan 23, 2017 8:36 PM, "Ryan Wehler" <wrwehler at gmail.com> wrote:

> I wonder if it's fixed in Access 2016. I could give my users that 
> runtime....
>
> I don't know that I've seen anyone else mention Access 2013 memory 
> inefficiencies aside from you and me.
>
> Really frustrating.
>
> Sent from my iPad
>
> > On Jan 23, 2017, at 7:27 PM, Bill Benson <bensonforums at gmail.com> wrote:
> >
> > Closing them does not affect the memory hoarding. If it did I would 
> > have solved the problem that way, but it just doesnt work, Ac2013 
> > has memory management problems.
> >
> > From my non-flammable Note 3,
> > Bill Benson
> >
> >> On Jan 23, 2017 8:07 PM, "Ryan Wehler" <wrwehler at gmail.com> wrote:
> >>
> >> 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
> >>
> >> --
> >> AccessD mailing list
> >> AccessD at databaseadvisors.com
> >> http://databaseadvisors.com/mailman/listinfo/accessd
> >> Website: http://www.databaseadvisors.com
> >>
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
--
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