Set regEx = nothing ?

G

Giles

if you Set regEx = New RegExp (classic ASP, IIS 5+), do you need to destroy
it after use, e.g. Set regEx = nothing ?
Thanks
 
J

Jon Wallace

Hi Giles,

There are many ways to look at this and different people will give you
different responses. What that line in essense is doing is freeing up any
associated memory at was being used. The practise of cleaning up is
essential in languages such as C to avoid memory leaks - for example in the
following program.

1. Create a pointer to a blog of memory
2. Assign data to the blog of memory using the pointer
3. Use the data in the blog of memory using the pointer
4. Goto step 1

In the above example, step 4 takes you to the bigging at which point the
pointer would be changed to a different memory block but leaving the
original memory still in use and lost - this in essense is a memory leak.
This memory would eventually be freed but only when the process had
completed.

Now, argubly in languages such as VB, there are better controls to prevent
you from doing this and in your case when the scripting engine had finished
processing (when the page is delivered) such pointers and / or memory
allocation would be freed anyway. That's not to say things won't change in
the future however but I doubt it.

Long story short - although not specifically needed, get into the habbit of
cleaning up. Imagine you had a script that created 10 variables and stuck
100MB of data in each one, that would be 1GB of memory taken up until the
script finished. If you cleaned up the variabled you didn't need when you'd
finished you could use less memory.

Hope this makes sense...

Regards,
Jon

www.insidetheregistry.com
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top