Set regEx = nothing ?

Discussion in 'ASP General' started by Giles, Jun 10, 2009.

  1. Giles

    Giles Guest

    if you Set regEx = New RegExp (classic ASP, IIS 5+), do you need to destroy
    it after use, e.g. Set regEx = nothing ?
    Thanks
     
    Giles, Jun 10, 2009
    #1
    1. Advertising

  2. Giles

    Bob Barrows Guest

    Bob Barrows, Jun 10, 2009
    #2
    1. Advertising

  3. Giles

    Jon Wallace Guest

    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

    ---

    "Giles" <> wrote in message
    news:...
    > if you Set regEx = New RegExp (classic ASP, IIS 5+), do you need to
    > destroy it after use, e.g. Set regEx = nothing ?
    > Thanks
    >
     
    Jon Wallace, Jun 10, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    808
    Reedick, Andrew
    Jul 1, 2008
  2. Devin Jeanpierre
    Replies:
    2
    Views:
    511
    Devin Jeanpierre
    Feb 14, 2012
  3. Jack
    Replies:
    2
    Views:
    321
    Tad McClellan
    Oct 4, 2006
  4. John

    regex match on nothing

    John, Mar 4, 2010, in forum: Perl Misc
    Replies:
    3
    Views:
    143
  5. jwcarlton
    Replies:
    1
    Views:
    520
    Martin Honnen
    Feb 5, 2011
Loading...

Share This Page