Windows 2000 Developers have to have a good understanding of the Component Object Model (COM). In our last tip, The Lowdown on Threads," we discussed how COM facilitates the use of program threads. This tip, excerpted from InformIT, discusses the way that COM+ provides memory support for developers.
Along with threads, COM+ also provides support for managing the memory used for creating components. In the most efficient case, COM+ provides for pooling instances of objects created that might be reused by subsequent client calls. This mechanism of object pooling is designed to eliminate the overhead involved in object creation.
Object pooling works by taking objects that are released by calling clients and storing them in a common pool. The objects in this pool can then be retrieved for subsequent client calls without creating a new object instance. Unfortunately, object pooling requires that components show no thread affinity. For this reason, object pooling requires that components support the TNA model. Because Visual Basic 6.0 components can't be created using the TNA model, they can't support object pooling.
On the bright side, however, Visual Basic object creation routines are generally highly optimized. For this reason, lack of object pooling features won't significantly affect your application's overall performance. Having said this, you can bet Microsoft will be trumpeting object pooling as soon as it's possible under Visual Basic 7.0.
In the absence of object pooling, COM+ helps manage memory through the use of just-in-time activation and as-soon-as-possible deactivation. This feature ensures that an object lives for only the minimum amount of time necessary to process a function call. Effectively managing the available memory is critical to scaling a distributed application.
To read more of the article from which this tip has been excerpted, click over to InformIT. You have to register to read articles on the site, but registration is free.
This was first published in November 2000