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.

Closing Objects Explained


Question:

I am looping through opening and closing lots of files with Acrobat OLE. Is there any virtue in closing the intermediate objects opened when the file is opened. Or is it best to just wait until all looping finished before closing all the objects?

Answer:

Developers have a lot of discretion when writing COM servers so it is difficult to make any sweeping generalizations. For example, servers with multiple objects may require you to keep a parent object open while calling members of a child object but many do not require this. Some objects require you to release child and sibling object in the reverse order of acquisition but some do not.

When possible, I prefer to release objects as soon as I am finished with them because each object consumes an unknown amount of system and process resources. In some cases this amount is trivial but for some objects it can be significant.

On the other hand, I try to avoid repeatedly releasing and recreating the same object. This is because the process of instantiating an object can be expensive.

Newer versions of WB make object handling a lot easier because you can use nested object references. This reduces the number of object variables significantly. Object release is also simplified because it does not require a function call; you only need to perform variable reassignment.This can be a handy way to reuse a variable because the act of assigning a new object reference to a variable releases any existing object references without a function call.

Note: You have to adapt any "philosophy" to the object's implementation. Acrobat's COM implementation is known to be a little buggy. The newer versions of WB, with the new COM subsystem, even have code added for the specific purpose of working around some of these bugs.


Article ID:   W17086
File Created: 2007:07:03:14:28:14
Last Updated: 2007:07:03:14:28:14