Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VBS,IIS4,IIS5
Expertise: Intermediate
Jan 1, 2003



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Caution when reading arrays stored in Application and Session variable

One of the most effective optimization techniques consists of caching data inside Application or Session variables. However, you should pay attention to how you reference to the elements in those arrays from an ASP page. In fact, the syntax of VBScript (and JavaScript as well) lets you reference elements in those arrays as follows:

' read the first element
Response.Write Application("mydata")(0)
' read the second element
Response.Write Application("mydata")(1)
' etc.
Alas, when you do so VBScript makes a copy of the entire array and then extracts the requested element, and then discard the temporary copy. If the array is large, this causes a sensible overhead, in terms of memory allocation and deallocation. You can avoid these unnecessary operations using an explicit local variable:

Dim arr
' read the array in a local variable
arr = Application("mydata")
' read the elements
Response.Write arr(0)
Response.Write arr(1)
' etc.

Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date