<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx</link><description>Every so often some ASP coder out there tries to put a JScript or VBScript object into the Session (or Application) object. Things usually start going horribly wrong shortly thereafter -- either terrible performance ensues or things just break outright.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>RE: Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx#53051</link><pubDate>Fri, 19 Sep 2003 05:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53051</guid><dc:creator>Blake</dc:creator><description>Ah yes, on a related note, back in the era of the NT4 Option Pack I wrote a lot of code that involved stashing Scripting.Dictionary objects in both session and application scope.  These are normal COM objects and don't require a script engine, but fraught with their one problems.   I forget now which version of the runtime changed the threading model they were registered with and broke everything for me.</description></item><item><title>RE: Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx#53052</link><pubDate>Fri, 19 Sep 2003 08:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:53052</guid><dc:creator>Eric Lippert</dc:creator><description>Uh, yeah, that was my fault.  Sorry about that.  Everything you just read about ASP and threading is what I learned the day I marked the Scripting.Dictionary object as &amp;quot;Both&amp;quot; instead of &amp;quot;Apartment&amp;quot;.  I was young and foolish.  There were a number of lessons we learned that day, some of which I may post about later.</description></item><item><title>re: Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx#67974</link><pubDate>Thu, 05 Feb 2004 12:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:67974</guid><dc:creator>David Boccabella</dc:creator><description>I have been reading that the threading capabilities of the Dictionary object has been improved in IIS5 and thus it might be used as an Application variable.&lt;br&gt;&lt;br&gt;I am trying to speed up performace by caching results from recordsset into HTML snippets so to reduce database hits&lt;br&gt;&lt;br&gt;Dave </description></item><item><title>re: Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx#68106</link><pubDate>Thu, 05 Feb 2004 17:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:68106</guid><dc:creator>Eric Lippert</dc:creator><description>You heard wrong then.  No one has made a change to the Scripting.Dictionary object for many years now.&lt;br&gt;</description></item><item><title>re: Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx#128139</link><pubDate>Fri, 07 May 2004 21:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:128139</guid><dc:creator>Josh Painter</dc:creator><description>What about stashing a MSXML2.FreeThreadedDOMDocument.3.0 in a Session or Application variable?  Is it safer to do this since it is free-threaded?  If so, caching the XMLDOM object seems like a better alternative to parsing an XML page on each web page hit, correct?  Thanks for your great posts!</description></item><item><title>re: Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx#128140</link><pubDate>Fri, 07 May 2004 21:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:128140</guid><dc:creator>Eric Lippert</dc:creator><description>Free threaded objects are safe in session or application scope and do not introduce the performance penalty associated with marshaling.&lt;br&gt;&lt;br&gt;Of course, they might introduce a performance penalty associated with excessive lock contention -- without actually trying it out, it's hard to say.  &lt;br&gt;&lt;br&gt;Basically what I'm saying is &amp;quot;that should work, but you should try it and see for yourself&amp;quot;.  Armchair performance analysis is generally worth what you pay for it.&lt;br&gt;</description></item><item><title>re: Why is it a bad idea to put script objects in Session scope?</title><link>http://blogs.msdn.com/ericlippert/archive/2003/09/18/why-is-it-a-bad-idea-to-put-script-objects-in-session-scope.aspx#169244</link><pubDate>Tue, 29 Jun 2004 23:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:169244</guid><dc:creator>Bill Wilkinson</dc:creator><description>I have to ask...&lt;br&gt;&lt;br&gt;You suggest that if you must use Session &amp;quot;variables&amp;quot; (boy, I hate that name--your &amp;quot;Session Scope&amp;quot; is much cleaner, thanks), you should use strings.&lt;br&gt;&lt;br&gt;But consider:  The overhead in VBS of doing &lt;br&gt;    Session(&amp;quot;whatever&amp;quot;) = Join(someArray,&amp;quot;##&amp;quot;)&lt;br&gt;and then later doing&lt;br&gt;    someArray = Split( Session(&amp;quot;whatever&amp;quot;), &amp;quot;##&amp;quot; )&lt;br&gt;*surely* is worse than the needed copy-in-copy-out for an array?  Join may not be terribly &amp;quot;expensive&amp;quot;, but Split certainly is.  At least when you copy an array you already know how many elements are needed, what the size of each is, etc.&lt;br&gt;&lt;br&gt;On top of that, if you are actually working with a 2D array (e.g., the result of ADODB.RecordSet.GetRows), the process of converting that to a string has to be long and painfully slow VBS string concatenation, no?&lt;br&gt;&lt;br&gt;So the one exception I've always made to &amp;quot;don't store stuff in session scope&amp;quot; has always been 2D arrays.  I just can't think of a better storage mechanism (well, except maybe moving them to JS arrays on the client, but that's another topic).  [I won't argue if you want to tell me to go re-query the DB, but there *are* times where that's not very convenient and/or the performance may suck.]&lt;br&gt;&lt;br&gt;Naturally, I *always* use a single &amp;quot;copy in&amp;quot; at the start of the ASP page and a single &amp;quot;copy out&amp;quot; at the end of the page.  And then always work with VBS's local copy.&lt;br&gt;&lt;br&gt;Commentary?&lt;br&gt;</description></item></channel></rss>