Object lifecycle means the duration in which an object is valid for use between the time it is instantiated or created and then released or destroyed. There are two lifecycles to understand when working with the Export Bridge’s wrapper objects: the lifecycle of an instance of the wrapper object and the lifecycle of the underlying IDL object being wrapped.

The lifecycle of a wrapper object begins when an instance of the wrapper object is created within the client’s application. However, the underlying IDL object is not created until the CreateObject stock method is called on the wrapper object instance. Every wrapper object has a set of stock methods, including CreateObject and DestroyObject, which are used to manage the object lifecycle. (For more information, see Object Creation and Object Release)

Note: For Java objects, the method is createObject, which is a more Java-like method- naming scheme. When this section mentions method calls, COM capitalizes the first word, but Java does not.

When the CreateObject method is called, the underlying IDL process is created (if necessary), and an instance of the IDL object is created. The lifecycle of the IDL object continues until the DestroyObject stock method is called on the wrapper object instance. The lifecycle of the client’s wrapper object instance continues until it is released or destroyed using native language constructs.

Object Creation

Calling the CreateObject method on the wrapper object instance creates an instance of the underlying IDL object and calls its Init method with the specified parameters, if any. See CreateObject (COM) and createObject (Java) for language-specific calling conventions.

Object Release

Calling the DestroyObject method calls the underlying IDL object’s Cleanup method, if present; then the underlying IDL object itself is destroyed. Calling DestroyObject does not release or destroy the wrapper object instance within the client space. This happens when the release method is called on the wrapper instance. See DestroyObject (COM) and destroyObject (Java) for language-specific calling conventions.

Java uses a garbage-collection scheme to clean up memory. It is important that there are no references to the wrapper object remaining in the client application; otherwise, the Java Virtual Machine (JVM) will not garbage-collect the wrapper object.

Note: There can be a period of time between the call to the DestroyObject method and when the wrapper instance itself is released. During that period, no method calls on the wrapper instance can be made because the underlying IDL object no longer exists.