"Dave Anderson" <GTSPXOESSGOQ@spammotel.com> wrote in message
news:OttGIGphDHA.1820@TK2MSFTNGP09.phx.gbl...[color=blue]
> "Chris Hohmann" wrote:[color=green]
> >
> > 1. Create a recordset
> > 2. Retreive data (GetString/GetRows)
> > 3. Close recordset[/color]
>
> Agreed so far.
>
>[color=green]
> > 4. Set recordset to Nothing(null)
> > 5. Process rest of page[/color]
>
> Hmmm. Let me respond after a bit. But let's first look at how JScript[/color]
GC is[color=blue]
> described in the article you reference:
>
> 1. When the script engine is shut down, garbage is collected.
> 2. When 256 variants, or more than 64KB of strings, or more
> than 4096 array slots have been allocated, the garbage
> collector sets a flag that says collect soon.
> 3. Whenever a new statement is executed or the script debugger
> starts, that flag is checked, and if it is set, a collection
> is done.
>
> If this is true, then I'm not sure step 4 helps much, since GC *still*[/color]
needs[color=blue]
> to be triggered by a new statement (I'm assuming the script debugger[/color]
is not[color=blue]
> being used on the production server, where resources would really be[/color]
an[color=blue]
> issue). Continuing onward...[/color]
My point is that step 4 marks the recordsets as available for garbage
collection. It is step 5 that actually triggers the garbage collection.
For example:
rs.Close();
rs = null;
str = "This is a 64K length string...";
Response.Write("Hooray. RS is dead.");
[color=blue][color=green]
> > The key to all of this is that it is the act of setting the
> > recordset to Nothing(or null) that marks it for deletion by the GC.[/color]
>
> Marks *what* exactly? The variable is still in scope, and has been[/color]
assigned[color=blue]
> a value of null/Nothing. There is nothing in the GC description that
> outlines a process for marking something for deletion. I think it's[/color]
fair to[color=blue]
> say that loss of scope does the job, but I'm still unaware of any[/color]
definitive[color=blue]
> MS documentation on the matter. The delete operator is looking more
> legitimate by the day.[/color]
Here is an except from KB 164494:
When you set the object reference to null, the object is marked as
available for garbage collection, but it is not released until the
garbage collector runs or the script engine is destroyed:
[color=blue][color=green]
> > Without this step, the recordset is not marked for deletion until it
> > goes out of scope, ie.when the page finishes executing.[/color]
>
> Please show me something from MS that offers the complement -- that[/color]
WITH[color=blue]
> THIS STEP, it *is* marked for deletion. This is exactly the issue I[/color]
have[color=blue]
> been trying to resolve from day 1.[/color]
Please see above.
[color=blue][color=green]
> > By explicitly setting the recordset to Nothing(or null) we are
> > telling the GC to mark the recordset for deletion on its next
> > pass.[/color]
>
> In VBScript, I agree. In JScript, I await proof, or at least a[/color]
pursuasive[color=blue]
> argument. It has to be better than "that's the way it's done in[/color]
VBScript, so[color=blue]
> logic dictates it is the same in JScript".[/color]
Please see above.
[color=blue][color=green]
> > ...here's a link that describes how the GC is triggered in JScript:
> >
> >
http://msdn.microsoft.com/msdnmag/is...b/default.aspx[/color]
>
> ...and still nothing that describes how an object is MARKED for GC.[/color]
Please see above.
[color=blue][color=green]
> > However, with regards to the advantages of disconnected recordsets,
> > I refer you again to this article...
> >
> >
http://aspfaq.com/2467[/color]
>
> The word "disconnected" does not appear in that article. It's a[/color]
comparison[color=blue]
> of GetString(), GetRows(), and iteration. It does, however, say that[/color]
with[color=blue]
> iteration the recordset must remain open through the entire processing[/color]
and[color=blue]
> display cycle. This is incorrect on two measures: (1) there is no[/color]
display[color=blue]
> cycle, and (2) the code need not be structured so inefficiently.[/color]
Here's an[color=blue]
> example that improves on your sub-optimal model:[/color]
You neglected to quote the following:
"Specifically, in the pros/cons section of recordset iteration, it
discusses two (2) scenarios that can be acheive by using recordsets that
would be difficult if not impossible to achieve via GetRows/GetString.
This advantage applies equally to disconnected recordset. Disconnected
recordsets also benefit for the fact that they release their associated
connections back into the pool earlier in the processing cycle."
The point I was attempting to make is that recordsets, disconnected or
not, have benefits over GetRows/GetString. In addition to these benefits
which apply to both connected and disconnected recordsets, disconnected
recordset also have the benefit of releasing their connections earlier
than connected recordsets.
Also, to clarify, I intended "display cycle" to mean the phase of
processing that generates output to the Response buffer, which I think
you would agree, certainly exists. If you feel there is a more suitable
term, I would be happy to consider it.
[color=blue]
> var a = new Array(), RS = CN.Execute(sql)
> while (!RS.EOF) {
> a.push(
> new myObj(
> RS.Fields(key1).Item,
> RS.Fields(key2).Item,
> ...
> RS.Fields(keyN).Item
> )
> )
> RS.MoveNext()
> }
> RS.Close()
> CN.Close()
> a.sort(mySortFunction)
> ...
>
> ...later on:
>
> <A HREF="<%=a[i].Prop1%>"><%=a[i].Prop2%></A> ...[/color]
You have offered no proof that this method is more efficient. In
addition the article in question was written in a VBScript environment.
I only cited the article to provide examples where recordsets were
superior to GetRows/GetString, regardless of scripting language. And by
extension, that superioity also applies to disconnected recordsets. In a
JScript environment, there are other factors to be considered to be
sure. Specifically, I would not make such heavy use of the Response
object as it is late bound in JScript. But you already knew that.
[color=blue]
> Note that by the time the Response Buffer is flushed, the recordset[/color]
and[color=blue]
> connection were long ago closed. Note also that the only bit of[/color]
"processing[color=blue]
> cycle" during which the recordset is open is that bit devoted to[/color]
building[color=blue]
> and reading the recordset.[/color]
Using a disconnected recordset, you could have released the connection
object before building and reading the recordset.
[color=blue]
> I'm not going to dispute that GetRows() is faster than iteration, but[/color]
I will[color=blue]
> point out that your article does not compare JScript performance[/color]
differences[color=blue]
> between them. Is there additional overhead involved in stepping[/color]
through a[color=blue]
> VBArray Object (especially if a sort is in order)? Is it better to[/color]
keep a[color=blue]
> VBArray Object in scope than a Recordset Object? Give me a few days,[/color]
and[color=blue]
> I'll run a test on it, then perhaps offer an article to Aaron.[/color]
I stated previously and at the beginning of the article, the scripting
langauge was VBScript. I would certainly appreciate your sharing any
findings of a similar analysis in a JScript environment. I am sure Aaron
would appreciate it as well.
[color=blue][color=green]
> > If anything, disconnected recordsets improve connection
> > pooling since, as stated previously, the connection
> > associated with the recordset is released back into the
> > pool earlier in the processing cycle.[/color]
>
> I would like to know if that is indeed true. It is almost certainly[/color]
true[color=blue]
> that closing the connection improves pooling performance.[/color]
I guess the only way to find out would be to test it or take my word for
it. I recommend testing it.
[color=blue][color=green]
> > If you are talking about JScript, then those are fighting words![/color]
>
> I was, but only jokingly. JScript is way too cool to use anything else[/color]
for[color=blue]
> routine ASP tasks.[/color]
Disaster averted.
[color=blue][color=green]
> > OK, just so we are clear. We are in agreement that "bad
> > practices", as well as practices that are not categorized
> > as "bad", both necessitate this type of compensation. Is
> > that accurate?[/color]
>
> Yes.[/color]
Great, I feel like progress is being made.
-Chris