Kbase P90589: ACTIVEX - Microsoft Excel process still in memory after closing application when COM-HANDLE variable
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
Status: Verified
SYMPTOM(s):
Microsoft Excel process still in memory after closing the Progress Application
In the code a COM-HANDLE variable is reused for a new object
Quit method is correctly used.
CAUSE:
The memory used from the first COM-HANDLE object may be not released when the COM-HANDLE is repointed to the second one. This causes the process to be in memory after the application is correctly closed.
FIX:
A code like this will not release the Process:
DEF VAR excelWorkSheet AS COM-HANDLE.
DEF VAR excelProgramm AS COM-HANDLE.
CREATE "Excel.Application":U excelProgramm.
excelProgramm:Workbooks:OPEN("myFile.xls") NO-ERROR.
excelWorkSheet = excelProgramm:workSheets(1).
excelWorkSheet = excelProgramm:workSheets(2).
excelProgramm:ActiveWorkbook:Save().
excelprogramm:QUIT().
RELEASE OBJECT excelworksheet.
RELEASE OBJECT excelProgramm.
The reason why Excel stay in memory is that when the excelWorkSheet COM-HANDLE is first pointed to workSheets(1) and after to workSheets(2) the portion of memory workSheets(1) is not cleaned by the memory. Release the COM-HANDLE before assigning a new value to it solves the problem:
excelWorkSheet = excelProgramm:workSheets(1).
RELEASE OBJECT excelWorkSheet.
excelWorkSheet = excelProgramm:workSheets(2).