When I open an XLAM file directly (without using it as an Add-In) and run a macro, the memory is not released after the macro ends. This issue persists even after hitting the reset button in the VBA Editor. The memory is only released when the file is closed. This problem occurs exclusively with Office 365 64-bit and not with the previously used 32-bit version.
Example code used to test this out:
Option Explicit
Public Sub test()
Dim i As Long
Dim d As Dictionary
Set d = New Dictionary
For i = 1 To 1000000
d.Add i, "0123456789"
Next
Set d = Nothing
End Sub
Each execution of this macro (if executed form an XLAM file) increases memory usage by approximately 50MB to 100MB.
I have an XLSX file that stores the data and an XLAM file that provides the macros. I open both files simultaneously, allowing the macros to be used from the XLSX file, similar to how they would be if the XLAM were an Add-In. However, I prefer not to use it as an Add-In because it would load for all Excel files, even when not needed. While there are methods to dynamically activate and deactivate Add-Ins, this requires the data file to also contain macros. Additionally, managing different versions of the XLAM would be more complicated if used as an Add-In.
Not working version:
Microsoft® Excel® für Microsoft 365 MSO (Version 2408 Build 16.0.17928.20114) 64 Bit
Working version:
Microsoft® Excel® 2019 MSO (16.0.10413.20020) 32-Bit
Does anyone know why this behavior occurs?
Alex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.