03-18-2011 01:33 PM
If you are running an older version of LabWindows (like I am, v6.0) then you won't be able to track your resources. You will have to be very very very thorough in closing all handles, it is rather difficult sometimes, and buggy. http://forums.ni.com/t5/LabWindows-CVI/excel-memory-leaks-in-CVI/m-p/1290282
03-18-2011 07:15 PM
One more clue: be aware of the global object handles!
Caution must be taken when using global object handles declared in front of the main() funciton.
They must be cleared up properly, such as the ClearObjHandle() function in the example code excel2000dem.c, before re-assigning new values to them. Otherwise, the EXCEL.EXE won't quit, either.
03-19-2011 06:09 AM - edited 03-19-2011 06:10 AM
One additional clue.
Some object may be left pending if you happen to reuse a single variable to handle various objects one after the other: if you don't dispose of an object before you reuse the variable, it will remain in memory and prevent excel from closing properly. Disposing of the last object won't close all previous ones!
03-05-2019 09:44 AM - edited 03-05-2019 09:45 AM
Robert's post above was the problem I chased for a day in my code as well.
I had inadvertently redefined (reused) an ExcelObj_Worksheet handle variable twice. I was using it to access the same worksheet, but I had accidently called Excel_SheetsItem () more than once (a leftover from early code work). When you do that, another set of Excel resources are allocated each time, even though you only have the one declared object variable.
If you later use CA_DiscardObjHandle() on the object variable to clear it out, you're only clearing the Excel resources for the last time it was defined, not all the times. I got rid of the inadvertent second Excel_SheetsItem () call, Excel now shuts down properly in the Task Manager. Ahhhh...