Thread: Memory Leak
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Memory Leak

If you are convinced it is a memory leak then you can create an instance of
Excel for you add-in/processing to work with.
Close this instance every 10-15 runs and reopen another instance.
e.g. from an Excel VB

Const RUNS_REQUIRED As Long = 100
Dim InstanceCount As Long

Const MAX_RUNS As Long = 15
Dim RunCount As Long

Dim XLApp As Excel.Application

For InstanceCount = 1 To RUNS_REQUIRED / MAX_RUNS
Debug.Print InstanceCount
Set XLApp = New Excel.Application

'load the add-in, as is not loaded by default with automation

For RunCount = 1 To MAX_RUNS
'processing code
Debug.Print "Process : " & RunCount
Next

XLApp.Quit
Next

You would obviously need to calculate the number of loops correctly.

NickHK

"Sakkie" wrote in message
ups.com...
I am using a VBA macro in Excel 2003 to download data from a server.
The macro opens up a workbook containing equations (functions) in an
Add-In provided by the company who's software is running on the server.


So the process is:
1. Opening the workbook containing the equations pointing to the Add
In, the functions are updated (i.e. data downloaded from server).
2. Copy the results, pastes it in a new workbook (as values), save the
new workbook and close it.

This process is repeated.

I cannot edit or see the code of the Add In (password protected). The
Add In apparently has a memory leak, because my memory is just filling
up (after a +- 30 cycles, I cannot open a new workbook any more - "Out
of memory"). I am sure it is not my code. If I replace all the
equations downloading data from the server with "Rand()", i.e. having
the same number of cells with the same amount of data, my memory usage
stays constant for endless(?) cycles.

So, what I need is some sort of workaround.

Closing Excel clears the memory.

I tried just de-selecting the add-in and then reselecting it
(Tools--Add-Ins), this does not work.

So I think what I need is somehow to automatically close Excel, re-open
it and cary on with the macro. Any ideas?