home navigator pointer resources navigator pointer asp tips navigator pointer components and session/application
The definitive ASP tips page
tips menu | printable single page version

Note: this is my old ASP tips page and is no longer supported. See the new Visualize web site..

ASP Coding and Style - Beware of storing components at session/application level

Storing a component in the session or application object often seems the ideal thing to do, ie we simply set up the object "once" at session or application start up, and this is cached until we need it - no need to keep creating it and destroying it on each page and this should result in excellent performance. This is fine, and is a good idea, providing the component is designed to be used in this way. Many are not however, including those written in Visual Basic 6!

The only components that should be used in this way are those classed as "truly free-threaded" (or "agile" in Microsoft speak). These are written to allow multiple-threads to run safely, concurrently within the component, catering for all the issues that can arise, such as mutual exclusion problems, lockout or deadlock situations and controlling access to shared data.

Hence, only store components at session or application level if you know that the component is truly multi-threaded. Those created with VB6 (or below) will not be and should therefore only be used at the page level.

 

DISCLAIMER: Note these pages are a free resource for anyone wishing to reference them. Although every care is taken to ensure their correctness, the author takes no responsibility for any errors or problems that may occur through their use, or indeed misuse. These pages are copyight of Dave Clarke, Visualize Software Ltd 1997-2000 (all rights reserved).


 


© Copyright Dave Clarke, 1996-2010