Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  advice: Server.MapPath is Good
     [next Lesson]  advice: Don't Read COM Properties Twice

ASP Commandment #7: No COM objects in Sessions

Do not store any COM objects in a Session() variable because of memory waste and threading issues. Do not store any COM objects in an Application() variable unless the reasons are excellent because of concurrent access issues. For even more details:

Memory Waste Scenarios

Let us examine a typical usage pattern:

+  100  people hit your site for a couple of pages and leave
+ 100  new people arrive in a couple of minutes
+ 200  people arrive after that and leave within a couple of minutes and then
+  50  people arrive

Scenario 1:
object in session_onstart
Scenario 2: objects created/destroyed on a page per page basis
End Result:
450 sessions/objects in memory

with 50 people on your site. And dozens or hundred of threads that can't be reclaimed for a while
End Result:
50 objects in memory
with 50 people on your site. No unused threads must be kept in memory.

Connection pooling or MTX object caching may actually result in more than 50 objects in memory in the   Scenario 2 and more than 450 objects in Scenario 1 for better performance. Basically set object=nothing may be ignored and the object placed in an "instant ready" pool to be used by the next server.createobject request.

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site