IIS4 application variable removal

N

nutso fasst

Hi. Any way to do this from asp page in IIS4? Application.Contents.Remove is
IIS 5+. Setting variable to empty string does not remove variable.

thx,
nf
 
S

Slim

try something like this

for each val in Application.contents
Application(val) = null
next
 
B

Bob Barrows [MVP]

nutso said:
Hi. Any way to do this from asp page in IIS4?
Application.Contents.Remove is IIS 5+. Setting variable to empty
string does not remove variable.

I suspect Set Application("var") = Nothing will suit your purpose.
 
N

nutso fasst

Bob Barrows said:
I suspect Set Application("var") = Nothing will suit your purpose.

No, that produces an error. And this:
Set Application("var") = Nothing
creates an empty object. The variable is not removed.

Guess I'll just have to work with arrays stored in variables declared in
global.asa. No remove function was dumb!

thx 4 reply,
nf
 
N

nutso fasst

Slim said:
try something like this

for each val in Application.contents
Application(val) = null
next

Nope, setting the variables to null doesn't remove the variables.

thx,
nf
 
B

Bob Barrows [MVP]

nutso said:
No, that produces an error. And this:
Set Application("var") = Nothing

How is this any different from what I wrote?
creates an empty object.

or dereferences an existing one.
The variable is not removed.

Guess I'll just have to work with arrays stored in variables declared
in global.asa. No remove function was dumb!
I don't understand the requirement to "remove" the variable. If your
goal is simply to reclaim memory space, then setting the variable to
nothing should do that.
 
N

nutso fasst

Bob Barrows said:
How is this any different from what I wrote?

I see now it's not (said the blind carpenter, as he picked up his hammer and
saw).
or dereferences an existing one.

In this case it changed an existing item into an object reference.
I don't understand the requirement to "remove" the variable. If your
goal is simply to reclaim memory space, then setting the variable to
nothing should do that.

That doesn't quite happen. Using this code to show variables:

For Each Item in Application.Contents
If IsObject(Application.Contents(Item)) Then
Response.Write Item & " is an object.<br>"
ElseIf IsArray(Application.Contents(Item)) Then
Response.Write Item & " is an array.<br>"
Else
Response.Write Item & "=" & Application.Contents(Item) & "<br>"
End If
Next

Whether I assign it a null value or an empty string, or set it to Nothing
(in which case the above code reports it has become an object), the variable
is still there. If the variable exists then there is still memory being used
for the variable. So dynamically creating application variables with names
based on visitor IP addresses, for example, will constitute a virtual memory
leak as the Application.Contents collection grows and grows.

nf
 
B

Bob Barrows [MVP]

nutso said:
In this case it changed an existing item into an object reference.

Why is that relevant? The memory occupied by a reference to Nothing should
be negligable. It should certainly be less than the memory previously
occupied by that variable.
Whether I assign it a null value or an empty string, or set it to
Nothing (in which case the above code reports it has become an
object), the variable is still there. If the variable exists then
there is still memory being used for the variable. So dynamically
creating application variables with names based on visitor IP
addresses, for example, will constitute a virtual memory leak as the
Application.Contents collection grows and grows.
Ah. OK. Have you tested the effect of such a "leak" on your appliction? If
so, and your testing indicates that it will cause a problem, then yes, you
will need to use some sort of array- or xml document-based solution (if the
latter, make sure you use the free-threaded version, or simply store the xml
string)

You should be aware that arrays have their own "issues", i.e., the inability
to remove elements except from the end of the array. Javascript arrays are
superior to vbscript arrays in this respect. Also, since you will need to
lock and unlock application when updating this variable, you will cause it
to be serialized, impacting your application's performance.
 
N

nutso fasst

Bob Barrows said:
You should be aware that arrays have their own "issues", i.e., the inability
to remove elements except from the end of the array. Javascript arrays are
superior to vbscript arrays in this respect. Also, since you will need to

Yeah, slice is nice. In this case the only messing with the middle of an
array is to remove matching items, which I'm doing thusly:

myarray = Split(Replace(Replace(Replace(Join(myarray),remitem & " ","")," "
& remitem,""),remitem,"")
lock and unlock application when updating this variable, you will cause it
to be serialized, impacting your application's performance.

Yep. Just have to see how it goes.

Anyway, the no-remove limitation was actually a good thing as it works
better keeping the dynamic variables on the client.

thx,
nf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top