Wednesday, July 21, 2004

VJs Tip Of The Day - July 21th 2004

Performance with static variables as compared to Application variables

Sometimes if you want to share a value of a type across pages then it is sensible to use static variables instead of Application variable... The advantages from performance perspective by taking this approach are:

Storing and reading a value can be many times faster with static variables as they do not require to lookup into application variables collection when you refer to them...

You also do not need to cast from object to a specific type, as you need to do with Application variables, but you need to make sure that you declare the static variable of same type as the object that needs to be stored... By this you can also avoid the overhead casting, boxing and unboxing...

No comments: