Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Temporary Use of Session Object

Reply
Thread Tools

Temporary Use of Session Object

 
 
jamie.jamazon@googlemail.com
Guest
Posts: n/a
 
      10-29-2007
I'm currently developing a small MVC framework using classic ASP
(don't ask me why!) At it's core it calls the controller script which
does the heavy logic and builds disconnected recordsets of the
required data then transparently "includes" a page template asp script
using a Server.Execute.

Because of the limitations of Server.Execute and Server.Transfer the
data generated by the controller needs to be persisted past the
Server.Execute call by placing it into the Session Object. At the end
of each request everything placed into the Session object is removed
and the session is abandoned. Session.Timeout is also set to 1 at the
start of each request. I don't want or require anything to persist
past each request (contrary to the traditional role of session
variables) so this isn't a problem. I have a more robust database
session management system for this.

My question is, am I going to run into any scalability issues while
using the Session object in this way? I've heard whispers of thread
locking and heap fragmentation linked to storing large amounts of data
in Session, but I get the feeling this might only be so much of a
problem if the data is being persisted for the default 20 mins or
longer with each request.

Please feel free to shoot me down in flames here... or suggest an
alternative approach to persisting data through a Server.Execute/
Transfer

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      10-29-2007
wrote on 29 okt 2007 in microsoft.public.inetserver.asp.general:

> I'm currently developing a small MVC framework using classic ASP


> (don't ask me why!)


I think you are a bit insulting.

It is like asking a group of car lovers how to service a gearbox, and at
the same time telling them you think they are idiots not to use planes
exclusively for their transport.

Classic ASP, especially the jscript form, is far more chalenging to the
programmes mind to produce clean, consize, in depth understandable and
analysable code than the deaded .net form, you probably are referring to.

> At it's core it calls the controller script which
> does the heavy logic and builds disconnected recordsets of the
> required data then transparently "includes" a page template asp script
> using a Server.Execute.
>
> Because of the limitations of Server.Execute and Server.Transfer the
> data generated by the controller needs to be persisted past the
> Server.Execute call by placing it into the Session Object. At the end
> of each request everything placed into the Session object is removed
> and the session is abandoned. Session.Timeout is also set to 1 at the
> start of each request. I don't want or require anything to persist
> past each request (contrary to the traditional role of session
> variables) so this isn't a problem. I have a more robust database
> session management system for this.
>
> My question is, am I going to run into any scalability issues while
> using the Session object in this way?


Programming is all about testing.

> I've heard whispers of thread
> locking and heap fragmentation linked to storing large amounts of data
> in Session, but I get the feeling this might only be so much of a
> problem if the data is being persisted for the default 20 mins or
> longer with each request.


Why 20 minutes?

Try:

===== file1.asp =========
.....
session("transferrer") = myData
Server.transfer "file2.asp"
%>

===== file2.asp =========
<%
myData = session("transferrer")
Session.Contents.Remove("transferrer")
.....


Surely the persistence is in the order of a millisecond or so, not 20
minutes?

> Please feel free to shoot me down in flames here... or suggest an
> alternative approach to persisting data through a Server.Execute/
> Transfer


There seems to be no reason to kill the session object for this.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
 
jamie.jamazon@googlemail.com
Guest
Posts: n/a
 
      10-29-2007
Sorry i think you appear to have misunderstood my question. I'm not
sure if perhaps this is a language barrier thing, but i get the
distinct impression that you belive i am trying to suggest that
Classic ASP is not a serious development platform, This is not the
case

> Classic ASP, especially the jscript form, is far more chalenging to the

programmes mind to produce clean, consize, in depth understandable and
analysable code than the deaded .net form, you probably are referring
to.

Yes, i know. That's why i'm using it

> Why 20 minutes?


20 minutes is the default session timeout, which i change to 1 to
avoid accidental persistence of large recordset objects between
requests.

> Surely the persistence is in the order of a millisecond or so, not 20 minutes?


Indeed. This is what i am trying to achieve. The problem is not one of
persistence. The question i was asking was one of scalability in terms
of memory/thread usage and possible heap memory fragmentation which
can occur when using the session object in such a way.

I'm sorry that you have been insulted by my question, but that really
wasn't my intention. I feel my questions are valid. I merely am
curious to know if others have used such an approach and if there are
implications i should be aware of before heading along the wrong
route.

 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-29-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I'm currently developing a small MVC framework using classic ASP
> (don't ask me why!) At it's core it calls the controller script which
> does the heavy logic and builds disconnected recordsets of the
> required data then transparently "includes" a page template asp script
> using a Server.Execute.
>
> Because of the limitations of Server.Execute and Server.Transfer the
> data generated by the controller needs to be persisted past the
> Server.Execute call by placing it into the Session Object. At the end
> of each request everything placed into the Session object is removed
> and the session is abandoned. Session.Timeout is also set to 1 at the
> start of each request. I don't want or require anything to persist
> past each request (contrary to the traditional role of session
> variables) so this isn't a problem. I have a more robust database
> session management system for this.
>
> My question is, am I going to run into any scalability issues while
> using the Session object in this way? I've heard whispers of thread
> locking and heap fragmentation linked to storing large amounts of data
> in Session, but I get the feeling this might only be so much of a
> problem if the data is being persisted for the default 20 mins or
> longer with each request.
>
> Please feel free to shoot me down in flames here... or suggest an
> alternative approach to persisting data through a Server.Execute/
> Transfer


The only reason you would run into threading issues is if you stored
single-threaded objects in Session or Application. ADO objects are, by
default, apartment-threaded, so they are not safe to store in Session or
Application. You mentioned disconnected recordsets ... are you putting the
recordsets themselves into Session? If so you do have a concern, since doing
so makes the Session object thread-bound, unless you make the registry
change to cause all ADO objects to be free-threaded. There's a batch file in
...\Program Files\Common Files\System\ADO called makfre15.bat that does this.
The problem with doing this is that you can no longer use a Jet backend
after you do it. So, if you are using Jet anywhere, you need to store the
data a different way. I usually create a free-threaded xml document
containing the data if I need to store it in session or application.

Immediately removing the objects from Session at the end of each request may
mitigate the problems, but i strongly feel you should rewrite things so you
store only scalar data or free-threaded objects in Session, which avoids the
problems in the first place.

I see no reason to abandon the session at the end of each request, or change
the timeout. Neither of these actions should have any effect on scalability.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      10-29-2007
wrote on 29 okt 2007 in microsoft.public.inetserver.asp.general:
> Sorry i think you appear to have misunderstood my question. I'm not
> sure if perhaps this is a language barrier thing, but i get the
> distinct impression that you belive i am trying to suggest that
> Classic ASP is not a serious development platform, This is not the
> case


OK.

Did you mean the jscript vs vbscript language barrier?



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      10-29-2007
"(E-Mail Removed)" wrote:

> I'm currently developing a small MVC framework using classic ASP
> (don't ask me why!) At it's core it calls the controller script which
> does the heavy logic and builds disconnected recordsets of the
> required data then transparently "includes" a page template asp script
> using a Server.Execute.
>
> Because of the limitations of Server.Execute and Server.Transfer the
> data generated by the controller needs to be persisted past the
> Server.Execute call by placing it into the Session Object. At the end
> of each request everything placed into the Session object is removed
> and the session is abandoned. Session.Timeout is also set to 1 at the
> start of each request. I don't want or require anything to persist
> past each request (contrary to the traditional role of session
> variables) so this isn't a problem. I have a more robust database
> session management system for this.
>
> My question is, am I going to run into any scalability issues while
> using the Session object in this way? I've heard whispers of thread
> locking and heap fragmentation linked to storing large amounts of data
> in Session, but I get the feeling this might only be so much of a
> problem if the data is being persisted for the default 20 mins or
> longer with each request.
>
> Please feel free to shoot me down in flames here... or suggest an
> alternative approach to persisting data through a Server.Execute/
> Transfer
>


To clear the contents of a session use Session.Contents.RemoveAll.

This is preferable than having the session timeout quickly (or deliberately
abandoning in the session with the abandon method). You should set the
session timeout to a reasonable period that your users will be running a
browser session that will be visiting your site.

Using session object to store variables isn't going to fragment memory
anymore than storing variables in any other way.

--
Anthony Jones - MVP ASP/ASP.NET

 
Reply With Quote
 
jamie.jamazon@googlemail.com
Guest
Posts: n/a
 
      10-29-2007
Thanks for the heads up on the batch file. I was planning on placing
the disconnected recordsets into the Session object and the thread-
binding is what was concerning me. I don't come from an ASP/VBScript
background.. or a Microsoft one at all for that matter so it's helpful
to get an insight into stuff like this. It's often difficult to find
advice on Classic ASP techniques and best practices as the community
isn't as large as it could or should be.

My application uses disconnected recordsets simply as arrays of data
with which to generate html. I could generate dictionary objects from
the recordsets but i believe these are apartment threaded also.

I agree about the Timeout and Abandon settings, these are both
unnecessary. I was thinking in terms of belt and braces garbage
collection, but i can see now that this was in error

 
Reply With Quote
 
jamie.jamazon@googlemail.com
Guest
Posts: n/a
 
      10-29-2007

> Did you mean the jscript vs vbscript language barrier?


heh, yeh

 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-29-2007
(E-Mail Removed) wrote:
> Thanks for the heads up on the batch file. I was planning on placing
> the disconnected recordsets into the Session object and the thread-
> binding is what was concerning me. I don't come from an ASP/VBScript
> background.. or a Microsoft one at all for that matter so it's helpful
> to get an insight into stuff like this. It's often difficult to find
> advice on Classic ASP techniques and best practices as the community
> isn't as large as it could or should be.
>
> My application uses disconnected recordsets simply as arrays of data
> with which to generate html. I could generate dictionary objects from
> the recordsets but i believe these are apartment threaded also.
>


Right. Arrays and free-threaded xml documents are certainly valid
alternatives.

Some further info can be seen here:
http://classicasp.aspfaq.com/compone...ion-scope.html


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
jamie.jamazon@googlemail.com
Guest
Posts: n/a
 
      10-29-2007
I'd like to say a big thankyou for the advice about using free-
threaded xml docs to store data. so simple yet so effective. i don't
know why i didn't think of this myself.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
anonymous array of strings // ("taking address of temporary"- how long is temporary valid?) anon.asdf@gmail.com C++ 7 02-12-2008 10:58 AM
creating a temporary object using dynamically created object Jess C++ 10 05-18-2007 02:21 PM
Stored Session object is mixed up with another user's session object. momo898 ASP .Net 2 10-12-2006 03:33 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Session (Temporary) Cookies - where are they stored under IE(6)? kublai khan Javascript 1 12-11-2004 02:21 AM



Advertisments