JIT Activation/Deactivation in COM+ (Views: 101)


What is JIT Activation/Deactivation? Why do we need this?


Why do we need this service?

In an application using COM objects, a COM object will be created when you call a method like CreateCOMObject etc., So once that method is called, that specific COM object will be created and the application can call the methods of that object. In other words, that COM object will be activated after that call to CreateCOMObject. Right.. That object will be in memory as long as any one of the applications is holding a reference to that object irrespective of whether that application is calling the object's methods or not. So the bottomline is a valuable memory resource is wasted if the application is not actively using the COM object.

JIT Activation/Deactivation is introduced in COM+ mainly for the effective usage of reources and to avoid the resource wastage as mentioned above.

What is JIT Activation/Deactivation?

It is one of the services provided by COM+ runtime.JIT stands for Just-In-Time. In COM+, we can set this service to a COM object through the Component Services Explorer.

How does it function?

Once you set this service to a COM object through the Component Services Explorer, the activation of that COM object is delayed until one of its methods is first called. So even though you call the CreateCOMObject methods and get a reference to that COM object, that object will not be activated until you call one of its methods. Also once every method call is completed, that COM object will be deactivated to conserve resource.


As I mentioned above, the main advantage is that the reources will be effectively used. Since every time you call a method/property of that COM object, that COM object will be activated every time. Consider the following scenerio:

  COMObj := CreateCOMObject("...");
  COMObj.Name := 'My Name';
  COMObj.SSN := '737387289';
  { ..................................
   ...............................etc., }

In the sample code above, I created a COM Object and set some properties and call UpdateDetails method to update the Name and SSN details. Let us assume that the COMObj is using the JIT Activation/Deactivation service provided in the Component Services Explorer. So every time a property value is assigned, a new COM object will be activated and deactivated once that value is assigned. Finally when you call the UpdateDetails method, a new COM object will be activated and it doesn't know anything of the previous assignment and so the values will not be updated. Then what is the use of this JIT Activation/Deactivation? We have to change the approach in writing COM object. The alternate for the above code would be like this:

  COMObj := CreateCOMObject("");
  COMObj.UpdateDetails "My Name", "737387289", ...etc.,

So after that call is over, the object will be deactivated. The method UpdateDetails will get all the info as parameters to that method. We can consider this either as an advantage or disadvantage.

Another question that comes to our mind now is how much time will that COM+ runtime take to activate/deactivate a COM object? But people using COM+ are claiming that the time taken to activate/deactivate a COM object is very less. How much? Do you people at Delphi3000 community have any ideas about that? Is it worth having JIT Activation/Deactivation service? Please feel free to post your views and letz start a discussion on that as I continue to explore more into COM and COM+. Also if any one of our community people have any experience on using these services, please feel free to share.

<< Back to main page