WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE COM ADO CDO ADSI LDAP
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Close an Object

 Keywords:  Close an Object Null String zero 0 Drop DropWild

Question:

I see how newer WB promotes just assigning an empty string to an object variable versus using the ObjectClose. Can you just Drop( ) the variable without having to reassign it? Or will that leave some OLE remnants behind?

Answer:

Yes, Drop and DropWild can be used to close object handles. Using Drop() a variable holding a COM object references has the same effect as reassigning the variable with respect to releasing COM object resources. However it is good programming practice to explicitly close object references using object = 0.

IMPORTANT: Most COM Automation objects support some method that closes the object and the application that created it. Since COM objects can use a significant amount of memory, it is a good idea to explicitly close an object when you no longer need it. To close an object. Use the appropriate method (most objects support the Close method or the Quit method).

For example:

;Closes the object.
objchart.Close

;Closes the application that created the object.
objchart.Quit

When WIL processing for an object is complete, set the object variable to a null string or 0 (zero) to free WIL processor memory. Like this:

objchart = ""
or
objchart = 0
or
Drop( objchart )

Reference:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP+Closing~Objects~Explained.txt

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP+Close~All~Open~OLE~COM~Objects.txt


Article ID:   W18016
Filename:   Close an Object.txt
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38